| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1 | // -*- C++ -*- | 
|  | 2 | //===------------------------------ vector --------------------------------===// | 
|  | 3 | // | 
| Howard Hinnant | f5256e1 | 2010-05-11 21:36:01 | [diff] [blame] | 4 | // The LLVM Compiler Infrastructure | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 5 | // | 
| Howard Hinnant | b64f8b0 | 2010-11-16 22:09:02 | [diff] [blame] | 6 | // This file is dual licensed under the MIT and the University of Illinois Open | 
|  | 7 | // Source Licenses. See LICENSE.TXT for details. | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 8 | // | 
|  | 9 | //===----------------------------------------------------------------------===// | 
|  | 10 |  | 
|  | 11 | #ifndef _LIBCPP_VECTOR | 
|  | 12 | #define _LIBCPP_VECTOR | 
|  | 13 |  | 
|  | 14 | /* | 
|  | 15 | vector synopsis | 
|  | 16 |  | 
|  | 17 | namespace std | 
|  | 18 | { | 
|  | 19 |  | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 20 | template <class T, class Allocator = allocator<T> > | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 21 | class vector | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 22 | { | 
|  | 23 | public: | 
|  | 24 | typedef T value_type; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 25 | typedef Allocator allocator_type; | 
|  | 26 | typedef typename allocator_type::reference reference; | 
|  | 27 | typedef typename allocator_type::const_reference const_reference; | 
|  | 28 | typedef implementation-defined iterator; | 
|  | 29 | typedef implementation-defined const_iterator; | 
|  | 30 | typedef typename allocator_type::size_type size_type; | 
|  | 31 | typedef typename allocator_type::difference_type difference_type; | 
|  | 32 | typedef typename allocator_type::pointer pointer; | 
|  | 33 | typedef typename allocator_type::const_pointer const_pointer; | 
|  | 34 | typedef std::reverse_iterator<iterator> reverse_iterator; | 
|  | 35 | typedef std::reverse_iterator<const_iterator> const_reverse_iterator; | 
|  | 36 |  | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 37 | vector() | 
|  | 38 | noexcept(is_nothrow_default_constructible<allocator_type>::value); | 
|  | 39 | explicit vector(const allocator_type&); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 40 | explicit vector(size_type n); | 
| Marshall Clow | a49a2c9 | 2013-09-14 00:47:59 | [diff] [blame] | 41 | explicit vector(size_type n, const allocator_type&); // C++14 | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 42 | vector(size_type n, const value_type& value, const allocator_type& = allocator_type()); | 
|  | 43 | template <class InputIterator> | 
|  | 44 | vector(InputIterator first, InputIterator last, const allocator_type& = allocator_type()); | 
|  | 45 | vector(const vector& x); | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 46 | vector(vector&& x) | 
|  | 47 | noexcept(is_nothrow_move_constructible<allocator_type>::value); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 48 | vector(initializer_list<value_type> il); | 
|  | 49 | vector(initializer_list<value_type> il, const allocator_type& a); | 
|  | 50 | ~vector(); | 
|  | 51 | vector& operator=(const vector& x); | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 52 | vector& operator=(vector&& x) | 
|  | 53 | noexcept( | 
| Marshall Clow | af961ed | 2015-08-18 18:57:00 | [diff] [blame] | 54 | allocator_type::propagate_on_container_move_assignment::value || | 
|  | 55 | allocator_type::is_always_equal::value); // C++17 | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 56 | vector& operator=(initializer_list<value_type> il); | 
|  | 57 | template <class InputIterator> | 
|  | 58 | void assign(InputIterator first, InputIterator last); | 
|  | 59 | void assign(size_type n, const value_type& u); | 
|  | 60 | void assign(initializer_list<value_type> il); | 
|  | 61 |  | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 62 | allocator_type get_allocator() const noexcept; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 63 |  | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 64 | iterator begin() noexcept; | 
|  | 65 | const_iterator begin() const noexcept; | 
|  | 66 | iterator end() noexcept; | 
|  | 67 | const_iterator end() const noexcept; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 68 |  | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 69 | reverse_iterator rbegin() noexcept; | 
|  | 70 | const_reverse_iterator rbegin() const noexcept; | 
|  | 71 | reverse_iterator rend() noexcept; | 
|  | 72 | const_reverse_iterator rend() const noexcept; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 73 |  | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 74 | const_iterator cbegin() const noexcept; | 
|  | 75 | const_iterator cend() const noexcept; | 
|  | 76 | const_reverse_iterator crbegin() const noexcept; | 
|  | 77 | const_reverse_iterator crend() const noexcept; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 78 |  | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 79 | size_type size() const noexcept; | 
|  | 80 | size_type max_size() const noexcept; | 
|  | 81 | size_type capacity() const noexcept; | 
|  | 82 | bool empty() const noexcept; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 83 | void reserve(size_type n); | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 84 | void shrink_to_fit() noexcept; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 85 |  | 
|  | 86 | reference operator[](size_type n); | 
|  | 87 | const_reference operator[](size_type n) const; | 
|  | 88 | reference at(size_type n); | 
|  | 89 | const_reference at(size_type n) const; | 
|  | 90 |  | 
|  | 91 | reference front(); | 
|  | 92 | const_reference front() const; | 
|  | 93 | reference back(); | 
|  | 94 | const_reference back() const; | 
|  | 95 |  | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 96 | value_type* data() noexcept; | 
|  | 97 | const value_type* data() const noexcept; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 98 |  | 
|  | 99 | void push_back(const value_type& x); | 
|  | 100 | void push_back(value_type&& x); | 
|  | 101 | template <class... Args> | 
| Marshall Clow | 4e42dc9 | 2017-01-24 23:09:12 | [diff] [blame] | 102 | reference emplace_back(Args&&... args); // reference in C++17 | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 103 | void pop_back(); | 
|  | 104 |  | 
|  | 105 | template <class... Args> iterator emplace(const_iterator position, Args&&... args); | 
|  | 106 | iterator insert(const_iterator position, const value_type& x); | 
|  | 107 | iterator insert(const_iterator position, value_type&& x); | 
|  | 108 | iterator insert(const_iterator position, size_type n, const value_type& x); | 
|  | 109 | template <class InputIterator> | 
|  | 110 | iterator insert(const_iterator position, InputIterator first, InputIterator last); | 
|  | 111 | iterator insert(const_iterator position, initializer_list<value_type> il); | 
|  | 112 |  | 
|  | 113 | iterator erase(const_iterator position); | 
|  | 114 | iterator erase(const_iterator first, const_iterator last); | 
|  | 115 |  | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 116 | void clear() noexcept; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 117 |  | 
|  | 118 | void resize(size_type sz); | 
|  | 119 | void resize(size_type sz, const value_type& c); | 
|  | 120 |  | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 121 | void swap(vector&) | 
| Marshall Clow | 7d914d1 | 2015-07-13 20:04:56 | [diff] [blame] | 122 | noexcept(allocator_traits<allocator_type>::propagate_on_container_swap::value || | 
|  | 123 | allocator_traits<allocator_type>::is_always_equal::value); // C++17 | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 124 |  | 
|  | 125 | bool __invariants() const; | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 126 | }; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 127 |  | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 128 | template <class Allocator = allocator<T> > | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 129 | class vector<bool, Allocator> | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 130 | { | 
|  | 131 | public: | 
|  | 132 | typedef bool value_type; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 133 | typedef Allocator allocator_type; | 
|  | 134 | typedef implementation-defined iterator; | 
|  | 135 | typedef implementation-defined const_iterator; | 
|  | 136 | typedef typename allocator_type::size_type size_type; | 
|  | 137 | typedef typename allocator_type::difference_type difference_type; | 
|  | 138 | typedef iterator pointer; | 
|  | 139 | typedef const_iterator const_pointer; | 
|  | 140 | typedef std::reverse_iterator<iterator> reverse_iterator; | 
|  | 141 | typedef std::reverse_iterator<const_iterator> const_reverse_iterator; | 
|  | 142 |  | 
|  | 143 | class reference | 
|  | 144 | { | 
|  | 145 | public: | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 146 | reference(const reference&) noexcept; | 
|  | 147 | operator bool() const noexcept; | 
|  | 148 | reference& operator=(const bool x) noexcept; | 
|  | 149 | reference& operator=(const reference& x) noexcept; | 
|  | 150 | iterator operator&() const noexcept; | 
|  | 151 | void flip() noexcept; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 152 | }; | 
|  | 153 |  | 
|  | 154 | class const_reference | 
|  | 155 | { | 
|  | 156 | public: | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 157 | const_reference(const reference&) noexcept; | 
|  | 158 | operator bool() const noexcept; | 
|  | 159 | const_iterator operator&() const noexcept; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 160 | }; | 
|  | 161 |  | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 162 | vector() | 
|  | 163 | noexcept(is_nothrow_default_constructible<allocator_type>::value); | 
| Howard Hinnant | 9cbee43 | 2011-09-02 20:42:31 | [diff] [blame] | 164 | explicit vector(const allocator_type&); | 
| Marshall Clow | a49a2c9 | 2013-09-14 00:47:59 | [diff] [blame] | 165 | explicit vector(size_type n, const allocator_type& a = allocator_type()); // C++14 | 
|  | 166 | vector(size_type n, const value_type& value, const allocator_type& = allocator_type()); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 167 | template <class InputIterator> | 
|  | 168 | vector(InputIterator first, InputIterator last, const allocator_type& = allocator_type()); | 
|  | 169 | vector(const vector& x); | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 170 | vector(vector&& x) | 
|  | 171 | noexcept(is_nothrow_move_constructible<allocator_type>::value); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 172 | vector(initializer_list<value_type> il); | 
|  | 173 | vector(initializer_list<value_type> il, const allocator_type& a); | 
|  | 174 | ~vector(); | 
|  | 175 | vector& operator=(const vector& x); | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 176 | vector& operator=(vector&& x) | 
|  | 177 | noexcept( | 
| Marshall Clow | af961ed | 2015-08-18 18:57:00 | [diff] [blame] | 178 | allocator_type::propagate_on_container_move_assignment::value || | 
|  | 179 | allocator_type::is_always_equal::value); // C++17 | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 180 | vector& operator=(initializer_list<value_type> il); | 
|  | 181 | template <class InputIterator> | 
|  | 182 | void assign(InputIterator first, InputIterator last); | 
|  | 183 | void assign(size_type n, const value_type& u); | 
|  | 184 | void assign(initializer_list<value_type> il); | 
|  | 185 |  | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 186 | allocator_type get_allocator() const noexcept; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 187 |  | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 188 | iterator begin() noexcept; | 
|  | 189 | const_iterator begin() const noexcept; | 
|  | 190 | iterator end() noexcept; | 
|  | 191 | const_iterator end() const noexcept; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 192 |  | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 193 | reverse_iterator rbegin() noexcept; | 
|  | 194 | const_reverse_iterator rbegin() const noexcept; | 
|  | 195 | reverse_iterator rend() noexcept; | 
|  | 196 | const_reverse_iterator rend() const noexcept; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 197 |  | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 198 | const_iterator cbegin() const noexcept; | 
|  | 199 | const_iterator cend() const noexcept; | 
|  | 200 | const_reverse_iterator crbegin() const noexcept; | 
|  | 201 | const_reverse_iterator crend() const noexcept; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 202 |  | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 203 | size_type size() const noexcept; | 
|  | 204 | size_type max_size() const noexcept; | 
|  | 205 | size_type capacity() const noexcept; | 
|  | 206 | bool empty() const noexcept; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 207 | void reserve(size_type n); | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 208 | void shrink_to_fit() noexcept; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 209 |  | 
|  | 210 | reference operator[](size_type n); | 
|  | 211 | const_reference operator[](size_type n) const; | 
|  | 212 | reference at(size_type n); | 
|  | 213 | const_reference at(size_type n) const; | 
|  | 214 |  | 
|  | 215 | reference front(); | 
|  | 216 | const_reference front() const; | 
|  | 217 | reference back(); | 
|  | 218 | const_reference back() const; | 
|  | 219 |  | 
|  | 220 | void push_back(const value_type& x); | 
| Marshall Clow | 4e42dc9 | 2017-01-24 23:09:12 | [diff] [blame] | 221 | template <class... Args> reference emplace_back(Args&&... args); // C++14; reference in C++17 | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 222 | void pop_back(); | 
|  | 223 |  | 
| Marshall Clow | 198a2a5 | 2013-08-13 23:54:12 | [diff] [blame] | 224 | template <class... Args> iterator emplace(const_iterator position, Args&&... args); // C++14 | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 225 | iterator insert(const_iterator position, const value_type& x); | 
|  | 226 | iterator insert(const_iterator position, size_type n, const value_type& x); | 
|  | 227 | template <class InputIterator> | 
|  | 228 | iterator insert(const_iterator position, InputIterator first, InputIterator last); | 
|  | 229 | iterator insert(const_iterator position, initializer_list<value_type> il); | 
|  | 230 |  | 
|  | 231 | iterator erase(const_iterator position); | 
|  | 232 | iterator erase(const_iterator first, const_iterator last); | 
|  | 233 |  | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 234 | void clear() noexcept; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 235 |  | 
|  | 236 | void resize(size_type sz); | 
|  | 237 | void resize(size_type sz, value_type x); | 
|  | 238 |  | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 239 | void swap(vector&) | 
| Marshall Clow | 7d914d1 | 2015-07-13 20:04:56 | [diff] [blame] | 240 | noexcept(allocator_traits<allocator_type>::propagate_on_container_swap::value || | 
|  | 241 | allocator_traits<allocator_type>::is_always_equal::value); // C++17 | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 242 | void flip() noexcept; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 243 |  | 
|  | 244 | bool __invariants() const; | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 245 | }; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 246 |  | 
|  | 247 | template <class Allocator> struct hash<std::vector<bool, Allocator>>; | 
|  | 248 |  | 
|  | 249 | template <class T, class Allocator> bool operator==(const vector<T,Allocator>& x, const vector<T,Allocator>& y); | 
|  | 250 | template <class T, class Allocator> bool operator< (const vector<T,Allocator>& x, const vector<T,Allocator>& y); | 
|  | 251 | template <class T, class Allocator> bool operator!=(const vector<T,Allocator>& x, const vector<T,Allocator>& y); | 
|  | 252 | template <class T, class Allocator> bool operator> (const vector<T,Allocator>& x, const vector<T,Allocator>& y); | 
|  | 253 | template <class T, class Allocator> bool operator>=(const vector<T,Allocator>& x, const vector<T,Allocator>& y); | 
|  | 254 | template <class T, class Allocator> bool operator<=(const vector<T,Allocator>& x, const vector<T,Allocator>& y); | 
|  | 255 |  | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 256 | template <class T, class Allocator> | 
|  | 257 | void swap(vector<T,Allocator>& x, vector<T,Allocator>& y) | 
|  | 258 | noexcept(noexcept(x.swap(y))); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 259 |  | 
|  | 260 | } // std | 
|  | 261 |  | 
|  | 262 | */ | 
|  | 263 |  | 
|  | 264 | #include <__config> | 
| Eric Fiselier | b379228 | 2016-02-20 00:19:45 | [diff] [blame] | 265 | #include <iosfwd> // for forward declaration of vector | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 266 | #include <__bit_reference> | 
|  | 267 | #include <type_traits> | 
|  | 268 | #include <climits> | 
|  | 269 | #include <limits> | 
|  | 270 | #include <initializer_list> | 
|  | 271 | #include <memory> | 
|  | 272 | #include <stdexcept> | 
|  | 273 | #include <algorithm> | 
|  | 274 | #include <cstring> | 
|  | 275 | #include <__split_buffer> | 
|  | 276 | #include <__functional_base> | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 277 |  | 
| Howard Hinnant | 66c6f97 | 2011-11-29 16:45:27 | [diff] [blame] | 278 | #include <__undef_min_max> | 
|  | 279 |  | 
| Eric Fiselier | b953610 | 2014-08-10 23:53:08 | [diff] [blame] | 280 | #include <__debug> | 
| Howard Hinnant | 8b00e6c | 2013-08-02 00:26:35 | [diff] [blame] | 281 |  | 
| Howard Hinnant | 08e1747 | 2011-10-17 20:05:10 | [diff] [blame] | 282 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 283 | #pragma GCC system_header | 
| Howard Hinnant | 08e1747 | 2011-10-17 20:05:10 | [diff] [blame] | 284 | #endif | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 285 |  | 
|  | 286 | _LIBCPP_BEGIN_NAMESPACE_STD | 
|  | 287 |  | 
|  | 288 | template <bool> | 
|  | 289 | class __vector_base_common | 
|  | 290 | { | 
|  | 291 | protected: | 
|  | 292 | _LIBCPP_ALWAYS_INLINE __vector_base_common() {} | 
| Marshall Clow | 14c09a2 | 2016-08-25 15:09:01 | [diff] [blame] | 293 | _LIBCPP_NORETURN void __throw_length_error() const; | 
|  | 294 | _LIBCPP_NORETURN void __throw_out_of_range() const; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 295 | }; | 
|  | 296 |  | 
|  | 297 | template <bool __b> | 
|  | 298 | void | 
|  | 299 | __vector_base_common<__b>::__throw_length_error() const | 
|  | 300 | { | 
| Marshall Clow | 14c09a2 | 2016-08-25 15:09:01 | [diff] [blame] | 301 | _VSTD::__throw_length_error("vector"); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 302 | } | 
|  | 303 |  | 
|  | 304 | template <bool __b> | 
|  | 305 | void | 
|  | 306 | __vector_base_common<__b>::__throw_out_of_range() const | 
|  | 307 | { | 
| Marshall Clow | 14c09a2 | 2016-08-25 15:09:01 | [diff] [blame] | 308 | _VSTD::__throw_out_of_range("vector"); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 309 | } | 
|  | 310 |  | 
| Howard Hinnant | e9df0a5 | 2013-08-01 18:17:34 | [diff] [blame] | 311 | #ifdef _LIBCPP_MSVC | 
| Howard Hinnant | 78b6828 | 2011-10-22 20:59:45 | [diff] [blame] | 312 | #pragma warning( push ) | 
|  | 313 | #pragma warning( disable: 4231 ) | 
| Howard Hinnant | e9df0a5 | 2013-08-01 18:17:34 | [diff] [blame] | 314 | #endif // _LIBCPP_MSVC | 
| Eric Fiselier | 833d644 | 2016-09-15 22:27:07 | [diff] [blame] | 315 | _LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __vector_base_common<true>) | 
| Howard Hinnant | e9df0a5 | 2013-08-01 18:17:34 | [diff] [blame] | 316 | #ifdef _LIBCPP_MSVC | 
| Howard Hinnant | 78b6828 | 2011-10-22 20:59:45 | [diff] [blame] | 317 | #pragma warning( pop ) | 
| Howard Hinnant | e9df0a5 | 2013-08-01 18:17:34 | [diff] [blame] | 318 | #endif // _LIBCPP_MSVC | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 319 |  | 
|  | 320 | template <class _Tp, class _Allocator> | 
|  | 321 | class __vector_base | 
|  | 322 | : protected __vector_base_common<true> | 
|  | 323 | { | 
|  | 324 | protected: | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 325 | typedef _Tp value_type; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 326 | typedef _Allocator allocator_type; | 
|  | 327 | typedef allocator_traits<allocator_type> __alloc_traits; | 
|  | 328 | typedef value_type& reference; | 
|  | 329 | typedef const value_type& const_reference; | 
|  | 330 | typedef typename __alloc_traits::size_type size_type; | 
|  | 331 | typedef typename __alloc_traits::difference_type difference_type; | 
|  | 332 | typedef typename __alloc_traits::pointer pointer; | 
|  | 333 | typedef typename __alloc_traits::const_pointer const_pointer; | 
|  | 334 | typedef pointer iterator; | 
|  | 335 | typedef const_pointer const_iterator; | 
|  | 336 |  | 
|  | 337 | pointer __begin_; | 
|  | 338 | pointer __end_; | 
|  | 339 | __compressed_pair<pointer, allocator_type> __end_cap_; | 
|  | 340 |  | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 341 | _LIBCPP_INLINE_VISIBILITY | 
|  | 342 | allocator_type& __alloc() _NOEXCEPT | 
|  | 343 | {return __end_cap_.second();} | 
|  | 344 | _LIBCPP_INLINE_VISIBILITY | 
|  | 345 | const allocator_type& __alloc() const _NOEXCEPT | 
|  | 346 | {return __end_cap_.second();} | 
|  | 347 | _LIBCPP_INLINE_VISIBILITY | 
|  | 348 | pointer& __end_cap() _NOEXCEPT | 
|  | 349 | {return __end_cap_.first();} | 
|  | 350 | _LIBCPP_INLINE_VISIBILITY | 
|  | 351 | const pointer& __end_cap() const _NOEXCEPT | 
|  | 352 | {return __end_cap_.first();} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 353 |  | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 354 | _LIBCPP_INLINE_VISIBILITY | 
|  | 355 | __vector_base() | 
|  | 356 | _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value); | 
| Howard Hinnant | 2d72b1e | 2010-12-17 14:46:43 | [diff] [blame] | 357 | _LIBCPP_INLINE_VISIBILITY __vector_base(const allocator_type& __a); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 358 | ~__vector_base(); | 
|  | 359 |  | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 360 | _LIBCPP_INLINE_VISIBILITY | 
|  | 361 | void clear() _NOEXCEPT {__destruct_at_end(__begin_);} | 
|  | 362 | _LIBCPP_INLINE_VISIBILITY | 
|  | 363 | size_type capacity() const _NOEXCEPT | 
|  | 364 | {return static_cast<size_type>(__end_cap() - __begin_);} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 365 |  | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 366 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 2c39cbe | 2013-06-27 19:35:32 | [diff] [blame] | 367 | void __destruct_at_end(pointer __new_last) _NOEXCEPT; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 368 |  | 
| Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 | [diff] [blame] | 369 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 370 | void __copy_assign_alloc(const __vector_base& __c) | 
|  | 371 | {__copy_assign_alloc(__c, integral_constant<bool, | 
|  | 372 | __alloc_traits::propagate_on_container_copy_assignment::value>());} | 
|  | 373 |  | 
| Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 | [diff] [blame] | 374 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 375 | void __move_assign_alloc(__vector_base& __c) | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 376 | _NOEXCEPT_( | 
|  | 377 | !__alloc_traits::propagate_on_container_move_assignment::value || | 
|  | 378 | is_nothrow_move_assignable<allocator_type>::value) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 379 | {__move_assign_alloc(__c, integral_constant<bool, | 
|  | 380 | __alloc_traits::propagate_on_container_move_assignment::value>());} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 381 | private: | 
| Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 | [diff] [blame] | 382 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 383 | void __copy_assign_alloc(const __vector_base& __c, true_type) | 
|  | 384 | { | 
|  | 385 | if (__alloc() != __c.__alloc()) | 
|  | 386 | { | 
|  | 387 | clear(); | 
|  | 388 | __alloc_traits::deallocate(__alloc(), __begin_, capacity()); | 
|  | 389 | __begin_ = __end_ = __end_cap() = nullptr; | 
|  | 390 | } | 
|  | 391 | __alloc() = __c.__alloc(); | 
|  | 392 | } | 
|  | 393 |  | 
| Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 | [diff] [blame] | 394 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | ec3773c | 2011-12-01 20:21:04 | [diff] [blame] | 395 | void __copy_assign_alloc(const __vector_base&, false_type) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 396 | {} | 
|  | 397 |  | 
| Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 | [diff] [blame] | 398 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 9cbee43 | 2011-09-02 20:42:31 | [diff] [blame] | 399 | void __move_assign_alloc(__vector_base& __c, true_type) | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 400 | _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 401 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 402 | __alloc() = _VSTD::move(__c.__alloc()); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 403 | } | 
|  | 404 |  | 
| Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 | [diff] [blame] | 405 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | ec3773c | 2011-12-01 20:21:04 | [diff] [blame] | 406 | void __move_assign_alloc(__vector_base&, false_type) | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 407 | _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 408 | {} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 409 | }; | 
|  | 410 |  | 
|  | 411 | template <class _Tp, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 | [diff] [blame] | 412 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 413 | void | 
| Howard Hinnant | 2c39cbe | 2013-06-27 19:35:32 | [diff] [blame] | 414 | __vector_base<_Tp, _Allocator>::__destruct_at_end(pointer __new_last) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 415 | { | 
| Bruce Mitchener | 50145cc | 2017-03-23 14:39:23 | [diff] [blame] | 416 | pointer __soon_to_be_end = __end_; | 
|  | 417 | while (__new_last != __soon_to_be_end) | 
|  | 418 | __alloc_traits::destroy(__alloc(), _VSTD::__to_raw_pointer(--__soon_to_be_end)); | 
|  | 419 | __end_ = __new_last; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 420 | } | 
|  | 421 |  | 
|  | 422 | template <class _Tp, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 | [diff] [blame] | 423 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 424 | __vector_base<_Tp, _Allocator>::__vector_base() | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 425 | _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value) | 
| Howard Hinnant | 2c39cbe | 2013-06-27 19:35:32 | [diff] [blame] | 426 | : __begin_(nullptr), | 
|  | 427 | __end_(nullptr), | 
|  | 428 | __end_cap_(nullptr) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 429 | { | 
|  | 430 | } | 
|  | 431 |  | 
|  | 432 | template <class _Tp, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 | [diff] [blame] | 433 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 434 | __vector_base<_Tp, _Allocator>::__vector_base(const allocator_type& __a) | 
| Howard Hinnant | 2c39cbe | 2013-06-27 19:35:32 | [diff] [blame] | 435 | : __begin_(nullptr), | 
|  | 436 | __end_(nullptr), | 
|  | 437 | __end_cap_(nullptr, __a) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 438 | { | 
|  | 439 | } | 
|  | 440 |  | 
|  | 441 | template <class _Tp, class _Allocator> | 
|  | 442 | __vector_base<_Tp, _Allocator>::~__vector_base() | 
|  | 443 | { | 
| Howard Hinnant | 2c39cbe | 2013-06-27 19:35:32 | [diff] [blame] | 444 | if (__begin_ != nullptr) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 445 | { | 
|  | 446 | clear(); | 
|  | 447 | __alloc_traits::deallocate(__alloc(), __begin_, capacity()); | 
|  | 448 | } | 
|  | 449 | } | 
|  | 450 |  | 
| Eric Fiselier | b379228 | 2016-02-20 00:19:45 | [diff] [blame] | 451 | template <class _Tp, class _Allocator /* = allocator<_Tp> */> | 
| Eric Fiselier | c3589a8 | 2017-01-04 23:56:00 | [diff] [blame] | 452 | class _LIBCPP_TEMPLATE_VIS vector | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 453 | : private __vector_base<_Tp, _Allocator> | 
|  | 454 | { | 
|  | 455 | private: | 
|  | 456 | typedef __vector_base<_Tp, _Allocator> __base; | 
| Marshall Clow | 1f50f2d | 2014-05-08 14:14:06 | [diff] [blame] | 457 | typedef allocator<_Tp> __default_allocator_type; | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 458 | public: | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 459 | typedef vector __self; | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 460 | typedef _Tp value_type; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 461 | typedef _Allocator allocator_type; | 
|  | 462 | typedef typename __base::__alloc_traits __alloc_traits; | 
|  | 463 | typedef typename __base::reference reference; | 
|  | 464 | typedef typename __base::const_reference const_reference; | 
|  | 465 | typedef typename __base::size_type size_type; | 
|  | 466 | typedef typename __base::difference_type difference_type; | 
|  | 467 | typedef typename __base::pointer pointer; | 
|  | 468 | typedef typename __base::const_pointer const_pointer; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 469 | typedef __wrap_iter<pointer> iterator; | 
|  | 470 | typedef __wrap_iter<const_pointer> const_iterator; | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 471 | typedef _VSTD::reverse_iterator<iterator> reverse_iterator; | 
|  | 472 | typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 473 |  | 
| Howard Hinnant | 02d5e18 | 2013-03-26 19:04:56 | [diff] [blame] | 474 | static_assert((is_same<typename allocator_type::value_type, value_type>::value), | 
|  | 475 | "Allocator::value_type must be same type as value_type"); | 
|  | 476 |  | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 477 | _LIBCPP_INLINE_VISIBILITY | 
| Marshall Clow | c912c0c | 2015-06-04 02:05:41 | [diff] [blame] | 478 | vector() _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value) | 
| Howard Hinnant | 7a563db | 2011-09-14 18:33:51 | [diff] [blame] | 479 | { | 
| Howard Hinnant | abe2628 | 2011-09-16 17:29:17 | [diff] [blame] | 480 | #if _LIBCPP_DEBUG_LEVEL >= 2 | 
| Howard Hinnant | 7a563db | 2011-09-14 18:33:51 | [diff] [blame] | 481 | __get_db()->__insert_c(this); | 
|  | 482 | #endif | 
|  | 483 | } | 
|  | 484 | _LIBCPP_INLINE_VISIBILITY explicit vector(const allocator_type& __a) | 
| Marshall Clow | 127db91 | 2015-06-04 00:10:20 | [diff] [blame] | 485 | #if _LIBCPP_STD_VER <= 14 | 
|  | 486 | _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value) | 
|  | 487 | #else | 
|  | 488 | _NOEXCEPT | 
|  | 489 | #endif | 
| Howard Hinnant | 7a563db | 2011-09-14 18:33:51 | [diff] [blame] | 490 | : __base(__a) | 
|  | 491 | { | 
| Howard Hinnant | abe2628 | 2011-09-16 17:29:17 | [diff] [blame] | 492 | #if _LIBCPP_DEBUG_LEVEL >= 2 | 
| Howard Hinnant | 7a563db | 2011-09-14 18:33:51 | [diff] [blame] | 493 | __get_db()->__insert_c(this); | 
|  | 494 | #endif | 
|  | 495 | } | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 496 | explicit vector(size_type __n); | 
| Marshall Clow | a49a2c9 | 2013-09-14 00:47:59 | [diff] [blame] | 497 | #if _LIBCPP_STD_VER > 11 | 
|  | 498 | explicit vector(size_type __n, const allocator_type& __a); | 
|  | 499 | #endif | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 500 | vector(size_type __n, const_reference __x); | 
|  | 501 | vector(size_type __n, const_reference __x, const allocator_type& __a); | 
|  | 502 | template <class _InputIterator> | 
| Howard Hinnant | de589f2 | 2013-09-21 21:13:54 | [diff] [blame] | 503 | vector(_InputIterator __first, | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 504 | typename enable_if<__is_input_iterator <_InputIterator>::value && | 
| Howard Hinnant | 742fecb | 2013-03-28 17:44:32 | [diff] [blame] | 505 | !__is_forward_iterator<_InputIterator>::value && | 
|  | 506 | is_constructible< | 
|  | 507 | value_type, | 
| Howard Hinnant | de589f2 | 2013-09-21 21:13:54 | [diff] [blame] | 508 | typename iterator_traits<_InputIterator>::reference>::value, | 
|  | 509 | _InputIterator>::type __last); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 510 | template <class _InputIterator> | 
|  | 511 | vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a, | 
|  | 512 | typename enable_if<__is_input_iterator <_InputIterator>::value && | 
| Howard Hinnant | 742fecb | 2013-03-28 17:44:32 | [diff] [blame] | 513 | !__is_forward_iterator<_InputIterator>::value && | 
|  | 514 | is_constructible< | 
|  | 515 | value_type, | 
|  | 516 | typename iterator_traits<_InputIterator>::reference>::value>::type* = 0); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 517 | template <class _ForwardIterator> | 
| Howard Hinnant | de589f2 | 2013-09-21 21:13:54 | [diff] [blame] | 518 | vector(_ForwardIterator __first, | 
| Howard Hinnant | 742fecb | 2013-03-28 17:44:32 | [diff] [blame] | 519 | typename enable_if<__is_forward_iterator<_ForwardIterator>::value && | 
|  | 520 | is_constructible< | 
|  | 521 | value_type, | 
| Howard Hinnant | de589f2 | 2013-09-21 21:13:54 | [diff] [blame] | 522 | typename iterator_traits<_ForwardIterator>::reference>::value, | 
|  | 523 | _ForwardIterator>::type __last); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 524 | template <class _ForwardIterator> | 
|  | 525 | vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a, | 
| Howard Hinnant | 742fecb | 2013-03-28 17:44:32 | [diff] [blame] | 526 | typename enable_if<__is_forward_iterator<_ForwardIterator>::value && | 
|  | 527 | is_constructible< | 
|  | 528 | value_type, | 
|  | 529 | typename iterator_traits<_ForwardIterator>::reference>::value>::type* = 0); | 
| Howard Hinnant | e3e3291 | 2011-08-12 21:56:02 | [diff] [blame] | 530 | #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS | 
| Howard Hinnant | 2d72b1e | 2010-12-17 14:46:43 | [diff] [blame] | 531 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 532 | vector(initializer_list<value_type> __il); | 
| Howard Hinnant | 2d72b1e | 2010-12-17 14:46:43 | [diff] [blame] | 533 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 534 | vector(initializer_list<value_type> __il, const allocator_type& __a); | 
| Howard Hinnant | e3e3291 | 2011-08-12 21:56:02 | [diff] [blame] | 535 | #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS | 
| Howard Hinnant | abe2628 | 2011-09-16 17:29:17 | [diff] [blame] | 536 | #if _LIBCPP_DEBUG_LEVEL >= 2 | 
| Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 | [diff] [blame] | 537 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 7a563db | 2011-09-14 18:33:51 | [diff] [blame] | 538 | ~vector() | 
|  | 539 | { | 
|  | 540 | __get_db()->__erase_c(this); | 
|  | 541 | } | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 542 | #endif | 
|  | 543 |  | 
|  | 544 | vector(const vector& __x); | 
|  | 545 | vector(const vector& __x, const allocator_type& __a); | 
| Howard Hinnant | 2d72b1e | 2010-12-17 14:46:43 | [diff] [blame] | 546 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 547 | vector& operator=(const vector& __x); | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 | [diff] [blame] | 548 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | 2d72b1e | 2010-12-17 14:46:43 | [diff] [blame] | 549 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 550 | vector(vector&& __x) | 
| Marshall Clow | 119ed47 | 2015-07-14 14:46:32 | [diff] [blame] | 551 | #if _LIBCPP_STD_VER > 14 | 
|  | 552 | _NOEXCEPT; | 
|  | 553 | #else | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 554 | _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value); | 
| Marshall Clow | 119ed47 | 2015-07-14 14:46:32 | [diff] [blame] | 555 | #endif | 
| Howard Hinnant | 2d72b1e | 2010-12-17 14:46:43 | [diff] [blame] | 556 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 557 | vector(vector&& __x, const allocator_type& __a); | 
| Howard Hinnant | 2d72b1e | 2010-12-17 14:46:43 | [diff] [blame] | 558 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 559 | vector& operator=(vector&& __x) | 
| Marshall Clow | af961ed | 2015-08-18 18:57:00 | [diff] [blame] | 560 | _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value)); | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 | [diff] [blame] | 561 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | e3e3291 | 2011-08-12 21:56:02 | [diff] [blame] | 562 | #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS | 
| Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 | [diff] [blame] | 563 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 564 | vector& operator=(initializer_list<value_type> __il) | 
|  | 565 | {assign(__il.begin(), __il.end()); return *this;} | 
| Howard Hinnant | e3e3291 | 2011-08-12 21:56:02 | [diff] [blame] | 566 | #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 567 |  | 
|  | 568 | template <class _InputIterator> | 
|  | 569 | typename enable_if | 
|  | 570 | < | 
|  | 571 | __is_input_iterator <_InputIterator>::value && | 
| Howard Hinnant | 742fecb | 2013-03-28 17:44:32 | [diff] [blame] | 572 | !__is_forward_iterator<_InputIterator>::value && | 
|  | 573 | is_constructible< | 
|  | 574 | value_type, | 
|  | 575 | typename iterator_traits<_InputIterator>::reference>::value, | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 576 | void | 
|  | 577 | >::type | 
|  | 578 | assign(_InputIterator __first, _InputIterator __last); | 
|  | 579 | template <class _ForwardIterator> | 
|  | 580 | typename enable_if | 
|  | 581 | < | 
| Howard Hinnant | 742fecb | 2013-03-28 17:44:32 | [diff] [blame] | 582 | __is_forward_iterator<_ForwardIterator>::value && | 
|  | 583 | is_constructible< | 
|  | 584 | value_type, | 
|  | 585 | typename iterator_traits<_ForwardIterator>::reference>::value, | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 586 | void | 
|  | 587 | >::type | 
|  | 588 | assign(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 589 |  | 
|  | 590 | void assign(size_type __n, const_reference __u); | 
| Howard Hinnant | e3e3291 | 2011-08-12 21:56:02 | [diff] [blame] | 591 | #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS | 
| Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 | [diff] [blame] | 592 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 593 | void assign(initializer_list<value_type> __il) | 
|  | 594 | {assign(__il.begin(), __il.end());} | 
| Howard Hinnant | e3e3291 | 2011-08-12 21:56:02 | [diff] [blame] | 595 | #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 596 |  | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 597 | _LIBCPP_INLINE_VISIBILITY | 
|  | 598 | allocator_type get_allocator() const _NOEXCEPT | 
|  | 599 | {return this->__alloc();} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 600 |  | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 601 | _LIBCPP_INLINE_VISIBILITY iterator begin() _NOEXCEPT; | 
|  | 602 | _LIBCPP_INLINE_VISIBILITY const_iterator begin() const _NOEXCEPT; | 
|  | 603 | _LIBCPP_INLINE_VISIBILITY iterator end() _NOEXCEPT; | 
|  | 604 | _LIBCPP_INLINE_VISIBILITY const_iterator end() const _NOEXCEPT; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 605 |  | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 606 | _LIBCPP_INLINE_VISIBILITY | 
|  | 607 | reverse_iterator rbegin() _NOEXCEPT | 
|  | 608 | {return reverse_iterator(end());} | 
|  | 609 | _LIBCPP_INLINE_VISIBILITY | 
|  | 610 | const_reverse_iterator rbegin() const _NOEXCEPT | 
|  | 611 | {return const_reverse_iterator(end());} | 
|  | 612 | _LIBCPP_INLINE_VISIBILITY | 
|  | 613 | reverse_iterator rend() _NOEXCEPT | 
|  | 614 | {return reverse_iterator(begin());} | 
|  | 615 | _LIBCPP_INLINE_VISIBILITY | 
|  | 616 | const_reverse_iterator rend() const _NOEXCEPT | 
|  | 617 | {return const_reverse_iterator(begin());} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 618 |  | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 619 | _LIBCPP_INLINE_VISIBILITY | 
|  | 620 | const_iterator cbegin() const _NOEXCEPT | 
|  | 621 | {return begin();} | 
|  | 622 | _LIBCPP_INLINE_VISIBILITY | 
|  | 623 | const_iterator cend() const _NOEXCEPT | 
|  | 624 | {return end();} | 
|  | 625 | _LIBCPP_INLINE_VISIBILITY | 
|  | 626 | const_reverse_iterator crbegin() const _NOEXCEPT | 
|  | 627 | {return rbegin();} | 
|  | 628 | _LIBCPP_INLINE_VISIBILITY | 
|  | 629 | const_reverse_iterator crend() const _NOEXCEPT | 
|  | 630 | {return rend();} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 631 |  | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 632 | _LIBCPP_INLINE_VISIBILITY | 
|  | 633 | size_type size() const _NOEXCEPT | 
|  | 634 | {return static_cast<size_type>(this->__end_ - this->__begin_);} | 
|  | 635 | _LIBCPP_INLINE_VISIBILITY | 
|  | 636 | size_type capacity() const _NOEXCEPT | 
|  | 637 | {return __base::capacity();} | 
|  | 638 | _LIBCPP_INLINE_VISIBILITY | 
|  | 639 | bool empty() const _NOEXCEPT | 
|  | 640 | {return this->__begin_ == this->__end_;} | 
|  | 641 | size_type max_size() const _NOEXCEPT; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 642 | void reserve(size_type __n); | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 643 | void shrink_to_fit() _NOEXCEPT; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 644 |  | 
|  | 645 | _LIBCPP_INLINE_VISIBILITY reference operator[](size_type __n); | 
|  | 646 | _LIBCPP_INLINE_VISIBILITY const_reference operator[](size_type __n) const; | 
|  | 647 | reference at(size_type __n); | 
|  | 648 | const_reference at(size_type __n) const; | 
|  | 649 |  | 
| Howard Hinnant | 7a563db | 2011-09-14 18:33:51 | [diff] [blame] | 650 | _LIBCPP_INLINE_VISIBILITY reference front() | 
|  | 651 | { | 
|  | 652 | _LIBCPP_ASSERT(!empty(), "front() called for empty vector"); | 
|  | 653 | return *this->__begin_; | 
|  | 654 | } | 
|  | 655 | _LIBCPP_INLINE_VISIBILITY const_reference front() const | 
|  | 656 | { | 
|  | 657 | _LIBCPP_ASSERT(!empty(), "front() called for empty vector"); | 
|  | 658 | return *this->__begin_; | 
|  | 659 | } | 
|  | 660 | _LIBCPP_INLINE_VISIBILITY reference back() | 
|  | 661 | { | 
|  | 662 | _LIBCPP_ASSERT(!empty(), "back() called for empty vector"); | 
|  | 663 | return *(this->__end_ - 1); | 
|  | 664 | } | 
|  | 665 | _LIBCPP_INLINE_VISIBILITY const_reference back() const | 
|  | 666 | { | 
|  | 667 | _LIBCPP_ASSERT(!empty(), "back() called for empty vector"); | 
|  | 668 | return *(this->__end_ - 1); | 
|  | 669 | } | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 670 |  | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 671 | _LIBCPP_INLINE_VISIBILITY | 
|  | 672 | value_type* data() _NOEXCEPT | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 673 | {return _VSTD::__to_raw_pointer(this->__begin_);} | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 674 | _LIBCPP_INLINE_VISIBILITY | 
|  | 675 | const value_type* data() const _NOEXCEPT | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 676 | {return _VSTD::__to_raw_pointer(this->__begin_);} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 677 |  | 
| Howard Hinnant | 2d72b1e | 2010-12-17 14:46:43 | [diff] [blame] | 678 | _LIBCPP_INLINE_VISIBILITY void push_back(const_reference __x); | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 | [diff] [blame] | 679 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | b0bfd9b | 2012-02-15 00:41:34 | [diff] [blame] | 680 | _LIBCPP_INLINE_VISIBILITY void push_back(value_type&& __x); | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 | [diff] [blame] | 681 | #ifndef _LIBCPP_HAS_NO_VARIADICS | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 682 | template <class... _Args> | 
| Evgeniy Stepanov | a3b25f8 | 2015-11-07 01:22:13 | [diff] [blame] | 683 | _LIBCPP_INLINE_VISIBILITY | 
| Marshall Clow | 4e42dc9 | 2017-01-24 23:09:12 | [diff] [blame] | 684 | #if _LIBCPP_STD_VER > 14 | 
| Eric Fiselier | 3816ef9 | 2016-07-21 03:20:17 | [diff] [blame] | 685 | reference emplace_back(_Args&&... __args); | 
| Marshall Clow | 4e42dc9 | 2017-01-24 23:09:12 | [diff] [blame] | 686 | #else | 
|  | 687 | void emplace_back(_Args&&... __args); | 
|  | 688 | #endif | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 | [diff] [blame] | 689 | #endif // _LIBCPP_HAS_NO_VARIADICS | 
|  | 690 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Evgeniy Stepanov | a3b25f8 | 2015-11-07 01:22:13 | [diff] [blame] | 691 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 692 | void pop_back(); | 
|  | 693 |  | 
|  | 694 | iterator insert(const_iterator __position, const_reference __x); | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 | [diff] [blame] | 695 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 696 | iterator insert(const_iterator __position, value_type&& __x); | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 | [diff] [blame] | 697 | #ifndef _LIBCPP_HAS_NO_VARIADICS | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 698 | template <class... _Args> | 
|  | 699 | iterator emplace(const_iterator __position, _Args&&... __args); | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 | [diff] [blame] | 700 | #endif // _LIBCPP_HAS_NO_VARIADICS | 
|  | 701 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 702 | iterator insert(const_iterator __position, size_type __n, const_reference __x); | 
|  | 703 | template <class _InputIterator> | 
|  | 704 | typename enable_if | 
|  | 705 | < | 
|  | 706 | __is_input_iterator <_InputIterator>::value && | 
| Howard Hinnant | 742fecb | 2013-03-28 17:44:32 | [diff] [blame] | 707 | !__is_forward_iterator<_InputIterator>::value && | 
|  | 708 | is_constructible< | 
|  | 709 | value_type, | 
|  | 710 | typename iterator_traits<_InputIterator>::reference>::value, | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 711 | iterator | 
|  | 712 | >::type | 
|  | 713 | insert(const_iterator __position, _InputIterator __first, _InputIterator __last); | 
|  | 714 | template <class _ForwardIterator> | 
|  | 715 | typename enable_if | 
|  | 716 | < | 
| Howard Hinnant | 742fecb | 2013-03-28 17:44:32 | [diff] [blame] | 717 | __is_forward_iterator<_ForwardIterator>::value && | 
|  | 718 | is_constructible< | 
|  | 719 | value_type, | 
|  | 720 | typename iterator_traits<_ForwardIterator>::reference>::value, | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 721 | iterator | 
|  | 722 | >::type | 
|  | 723 | insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last); | 
| Howard Hinnant | e3e3291 | 2011-08-12 21:56:02 | [diff] [blame] | 724 | #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS | 
| Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 | [diff] [blame] | 725 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 726 | iterator insert(const_iterator __position, initializer_list<value_type> __il) | 
|  | 727 | {return insert(__position, __il.begin(), __il.end());} | 
| Howard Hinnant | e3e3291 | 2011-08-12 21:56:02 | [diff] [blame] | 728 | #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 729 |  | 
| Howard Hinnant | 2d72b1e | 2010-12-17 14:46:43 | [diff] [blame] | 730 | _LIBCPP_INLINE_VISIBILITY iterator erase(const_iterator __position); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 731 | iterator erase(const_iterator __first, const_iterator __last); | 
|  | 732 |  | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 733 | _LIBCPP_INLINE_VISIBILITY | 
|  | 734 | void clear() _NOEXCEPT | 
| Howard Hinnant | 7a563db | 2011-09-14 18:33:51 | [diff] [blame] | 735 | { | 
| Marshall Clow | 1f50f2d | 2014-05-08 14:14:06 | [diff] [blame] | 736 | size_type __old_size = size(); | 
| Howard Hinnant | 7a563db | 2011-09-14 18:33:51 | [diff] [blame] | 737 | __base::clear(); | 
| Marshall Clow | 1f50f2d | 2014-05-08 14:14:06 | [diff] [blame] | 738 | __annotate_shrink(__old_size); | 
| Howard Hinnant | 7a563db | 2011-09-14 18:33:51 | [diff] [blame] | 739 | __invalidate_all_iterators(); | 
|  | 740 | } | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 741 |  | 
|  | 742 | void resize(size_type __sz); | 
|  | 743 | void resize(size_type __sz, const_reference __x); | 
|  | 744 |  | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 745 | void swap(vector&) | 
| Marshall Clow | 7d914d1 | 2015-07-13 20:04:56 | [diff] [blame] | 746 | #if _LIBCPP_STD_VER >= 14 | 
| Eric Fiselier | fb34238 | 2016-12-28 06:06:09 | [diff] [blame] | 747 | _NOEXCEPT_DEBUG; | 
| Marshall Clow | 7d914d1 | 2015-07-13 20:04:56 | [diff] [blame] | 748 | #else | 
| Eric Fiselier | fb34238 | 2016-12-28 06:06:09 | [diff] [blame] | 749 | _NOEXCEPT_DEBUG_(!__alloc_traits::propagate_on_container_swap::value || | 
| Marshall Clow | 7d914d1 | 2015-07-13 20:04:56 | [diff] [blame] | 750 | __is_nothrow_swappable<allocator_type>::value); | 
|  | 751 | #endif | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 752 |  | 
|  | 753 | bool __invariants() const; | 
|  | 754 |  | 
| Howard Hinnant | abe2628 | 2011-09-16 17:29:17 | [diff] [blame] | 755 | #if _LIBCPP_DEBUG_LEVEL >= 2 | 
| Howard Hinnant | 7a563db | 2011-09-14 18:33:51 | [diff] [blame] | 756 |  | 
|  | 757 | bool __dereferenceable(const const_iterator* __i) const; | 
|  | 758 | bool __decrementable(const const_iterator* __i) const; | 
|  | 759 | bool __addable(const const_iterator* __i, ptrdiff_t __n) const; | 
|  | 760 | bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const; | 
|  | 761 |  | 
| Howard Hinnant | abe2628 | 2011-09-16 17:29:17 | [diff] [blame] | 762 | #endif // _LIBCPP_DEBUG_LEVEL >= 2 | 
| Howard Hinnant | 7a563db | 2011-09-14 18:33:51 | [diff] [blame] | 763 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 764 | private: | 
| Howard Hinnant | 2d72b1e | 2010-12-17 14:46:43 | [diff] [blame] | 765 | _LIBCPP_INLINE_VISIBILITY void __invalidate_all_iterators(); | 
| Eric Fiselier | fb34238 | 2016-12-28 06:06:09 | [diff] [blame] | 766 | _LIBCPP_INLINE_VISIBILITY void __invalidate_iterators_past(pointer __new_last); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 767 | void allocate(size_type __n); | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 768 | void deallocate() _NOEXCEPT; | 
| Howard Hinnant | 2d72b1e | 2010-12-17 14:46:43 | [diff] [blame] | 769 | _LIBCPP_INLINE_VISIBILITY size_type __recommend(size_type __new_size) const; | 
| Howard Hinnant | 04240d9 | 2011-01-04 19:53:31 | [diff] [blame] | 770 | void __construct_at_end(size_type __n); | 
| Evgeniy Stepanov | a3b25f8 | 2015-11-07 01:22:13 | [diff] [blame] | 771 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 772 | void __construct_at_end(size_type __n, const_reference __x); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 773 | template <class _ForwardIterator> | 
|  | 774 | typename enable_if | 
|  | 775 | < | 
|  | 776 | __is_forward_iterator<_ForwardIterator>::value, | 
|  | 777 | void | 
|  | 778 | >::type | 
| Eric Fiselier | 088ed9f | 2015-03-31 16:54:19 | [diff] [blame] | 779 | __construct_at_end(_ForwardIterator __first, _ForwardIterator __last, size_type __n); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 780 | void __append(size_type __n); | 
|  | 781 | void __append(size_type __n, const_reference __x); | 
| Howard Hinnant | 2d72b1e | 2010-12-17 14:46:43 | [diff] [blame] | 782 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 783 | iterator __make_iter(pointer __p) _NOEXCEPT; | 
| Howard Hinnant | 2d72b1e | 2010-12-17 14:46:43 | [diff] [blame] | 784 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 785 | const_iterator __make_iter(const_pointer __p) const _NOEXCEPT; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 786 | void __swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v); | 
|  | 787 | pointer __swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v, pointer __p); | 
|  | 788 | void __move_range(pointer __from_s, pointer __from_e, pointer __to); | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 789 | void __move_assign(vector& __c, true_type) | 
|  | 790 | _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value); | 
| Marshall Clow | af961ed | 2015-08-18 18:57:00 | [diff] [blame] | 791 | void __move_assign(vector& __c, false_type) | 
|  | 792 | _NOEXCEPT_(__alloc_traits::is_always_equal::value); | 
| Howard Hinnant | 7a563db | 2011-09-14 18:33:51 | [diff] [blame] | 793 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 2c39cbe | 2013-06-27 19:35:32 | [diff] [blame] | 794 | void __destruct_at_end(pointer __new_last) _NOEXCEPT | 
| Howard Hinnant | 7a563db | 2011-09-14 18:33:51 | [diff] [blame] | 795 | { | 
| Eric Fiselier | fb34238 | 2016-12-28 06:06:09 | [diff] [blame] | 796 | __invalidate_iterators_past(__new_last); | 
| Marshall Clow | 1f50f2d | 2014-05-08 14:14:06 | [diff] [blame] | 797 | size_type __old_size = size(); | 
| Howard Hinnant | 7a563db | 2011-09-14 18:33:51 | [diff] [blame] | 798 | __base::__destruct_at_end(__new_last); | 
| Marshall Clow | 1f50f2d | 2014-05-08 14:14:06 | [diff] [blame] | 799 | __annotate_shrink(__old_size); | 
| Howard Hinnant | 7a563db | 2011-09-14 18:33:51 | [diff] [blame] | 800 | } | 
| Howard Hinnant | b0bfd9b | 2012-02-15 00:41:34 | [diff] [blame] | 801 | template <class _Up> | 
|  | 802 | void | 
|  | 803 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
|  | 804 | __push_back_slow_path(_Up&& __x); | 
|  | 805 | #else | 
|  | 806 | __push_back_slow_path(_Up& __x); | 
|  | 807 | #endif | 
| Howard Hinnant | 0438ea2 | 2012-02-26 15:30:12 | [diff] [blame] | 808 | #if !defined(_LIBCPP_HAS_NO_VARIADICS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) | 
|  | 809 | template <class... _Args> | 
|  | 810 | void | 
|  | 811 | __emplace_back_slow_path(_Args&&... __args); | 
|  | 812 | #endif | 
| Marshall Clow | 1f50f2d | 2014-05-08 14:14:06 | [diff] [blame] | 813 | // The following functions are no-ops outside of AddressSanitizer mode. | 
|  | 814 | // We call annotatations only for the default Allocator because other allocators | 
|  | 815 | // may not meet the AddressSanitizer alignment constraints. | 
|  | 816 | // See the documentation for __sanitizer_annotate_contiguous_container for more details. | 
| Marshall Clow | 1f50f2d | 2014-05-08 14:14:06 | [diff] [blame] | 817 | #ifndef _LIBCPP_HAS_NO_ASAN | 
| Eric Fiselier | 0e5ebbc | 2016-12-23 23:37:52 | [diff] [blame] | 818 | void __annotate_contiguous_container(const void *__beg, const void *__end, | 
|  | 819 | const void *__old_mid, | 
|  | 820 | const void *__new_mid) const | 
|  | 821 | { | 
|  | 822 |  | 
| Marshall Clow | 1f50f2d | 2014-05-08 14:14:06 | [diff] [blame] | 823 | if (__beg && is_same<allocator_type, __default_allocator_type>::value) | 
|  | 824 | __sanitizer_annotate_contiguous_container(__beg, __end, __old_mid, __new_mid); | 
| Marshall Clow | 1f50f2d | 2014-05-08 14:14:06 | [diff] [blame] | 825 | } | 
| Eric Fiselier | 0e5ebbc | 2016-12-23 23:37:52 | [diff] [blame] | 826 | #else | 
|  | 827 | _LIBCPP_INLINE_VISIBILITY | 
|  | 828 | void __annotate_contiguous_container(const void*, const void*, const void*, | 
|  | 829 | const void*) const {} | 
|  | 830 | #endif | 
|  | 831 | _LIBCPP_INLINE_VISIBILITY | 
|  | 832 | void __annotate_new(size_type __current_size) const { | 
| Marshall Clow | 1f50f2d | 2014-05-08 14:14:06 | [diff] [blame] | 833 | __annotate_contiguous_container(data(), data() + capacity(), | 
|  | 834 | data() + capacity(), data() + __current_size); | 
|  | 835 | } | 
| Eric Fiselier | 0e5ebbc | 2016-12-23 23:37:52 | [diff] [blame] | 836 |  | 
|  | 837 | _LIBCPP_INLINE_VISIBILITY | 
|  | 838 | void __annotate_delete() const { | 
| Marshall Clow | 1f50f2d | 2014-05-08 14:14:06 | [diff] [blame] | 839 | __annotate_contiguous_container(data(), data() + capacity(), | 
|  | 840 | data() + size(), data() + capacity()); | 
|  | 841 | } | 
| Eric Fiselier | 0e5ebbc | 2016-12-23 23:37:52 | [diff] [blame] | 842 |  | 
|  | 843 | _LIBCPP_INLINE_VISIBILITY | 
| Kostya Serebryany | 497f912 | 2014-09-02 23:43:38 | [diff] [blame] | 844 | void __annotate_increase(size_type __n) const | 
| Marshall Clow | 1f50f2d | 2014-05-08 14:14:06 | [diff] [blame] | 845 | { | 
|  | 846 | __annotate_contiguous_container(data(), data() + capacity(), | 
|  | 847 | data() + size(), data() + size() + __n); | 
|  | 848 | } | 
| Eric Fiselier | 0e5ebbc | 2016-12-23 23:37:52 | [diff] [blame] | 849 |  | 
|  | 850 | _LIBCPP_INLINE_VISIBILITY | 
| Kostya Serebryany | 497f912 | 2014-09-02 23:43:38 | [diff] [blame] | 851 | void __annotate_shrink(size_type __old_size) const | 
| Marshall Clow | 1f50f2d | 2014-05-08 14:14:06 | [diff] [blame] | 852 | { | 
|  | 853 | __annotate_contiguous_container(data(), data() + capacity(), | 
|  | 854 | data() + __old_size, data() + size()); | 
|  | 855 | } | 
| Marshall Clow | 26f472d | 2014-09-03 21:37:43 | [diff] [blame] | 856 | #ifndef _LIBCPP_HAS_NO_ASAN | 
| Kostya Serebryany | 497f912 | 2014-09-02 23:43:38 | [diff] [blame] | 857 | // The annotation for size increase should happen before the actual increase, | 
|  | 858 | // but if an exception is thrown after that the annotation has to be undone. | 
|  | 859 | struct __RAII_IncreaseAnnotator { | 
|  | 860 | __RAII_IncreaseAnnotator(const vector &__v, size_type __n = 1) | 
| Eric Fiselier | 9f4f221 | 2015-03-10 00:25:20 | [diff] [blame] | 861 | : __commit(false), __v(__v), __old_size(__v.size() + __n) { | 
| Kostya Serebryany | 497f912 | 2014-09-02 23:43:38 | [diff] [blame] | 862 | __v.__annotate_increase(__n); | 
|  | 863 | } | 
|  | 864 | void __done() { __commit = true; } | 
|  | 865 | ~__RAII_IncreaseAnnotator() { | 
|  | 866 | if (__commit) return; | 
| Eric Fiselier | 9f4f221 | 2015-03-10 00:25:20 | [diff] [blame] | 867 | __v.__annotate_shrink(__old_size); | 
| Kostya Serebryany | 497f912 | 2014-09-02 23:43:38 | [diff] [blame] | 868 | } | 
|  | 869 | bool __commit; | 
| Kostya Serebryany | 497f912 | 2014-09-02 23:43:38 | [diff] [blame] | 870 | const vector &__v; | 
| Eric Fiselier | 9f4f221 | 2015-03-10 00:25:20 | [diff] [blame] | 871 | size_type __old_size; | 
| Kostya Serebryany | 497f912 | 2014-09-02 23:43:38 | [diff] [blame] | 872 | }; | 
| Marshall Clow | 26f472d | 2014-09-03 21:37:43 | [diff] [blame] | 873 | #else | 
|  | 874 | struct __RAII_IncreaseAnnotator { | 
| Eric Fiselier | 0e5ebbc | 2016-12-23 23:37:52 | [diff] [blame] | 875 | _LIBCPP_INLINE_VISIBILITY | 
|  | 876 | __RAII_IncreaseAnnotator(const vector &, size_type = 1) {} | 
|  | 877 | _LIBCPP_INLINE_VISIBILITY void __done() {} | 
| Marshall Clow | 26f472d | 2014-09-03 21:37:43 | [diff] [blame] | 878 | }; | 
|  | 879 | #endif | 
|  | 880 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 881 | }; | 
|  | 882 |  | 
|  | 883 | template <class _Tp, class _Allocator> | 
|  | 884 | void | 
|  | 885 | vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v) | 
|  | 886 | { | 
| Marshall Clow | 1f50f2d | 2014-05-08 14:14:06 | [diff] [blame] | 887 | __annotate_delete(); | 
| Howard Hinnant | b0bfd9b | 2012-02-15 00:41:34 | [diff] [blame] | 888 | __alloc_traits::__construct_backward(this->__alloc(), this->__begin_, this->__end_, __v.__begin_); | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 889 | _VSTD::swap(this->__begin_, __v.__begin_); | 
|  | 890 | _VSTD::swap(this->__end_, __v.__end_); | 
|  | 891 | _VSTD::swap(this->__end_cap(), __v.__end_cap()); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 892 | __v.__first_ = __v.__begin_; | 
| Marshall Clow | 1f50f2d | 2014-05-08 14:14:06 | [diff] [blame] | 893 | __annotate_new(size()); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 894 | __invalidate_all_iterators(); | 
|  | 895 | } | 
|  | 896 |  | 
|  | 897 | template <class _Tp, class _Allocator> | 
|  | 898 | typename vector<_Tp, _Allocator>::pointer | 
|  | 899 | vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v, pointer __p) | 
|  | 900 | { | 
| Marshall Clow | 1f50f2d | 2014-05-08 14:14:06 | [diff] [blame] | 901 | __annotate_delete(); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 902 | pointer __r = __v.__begin_; | 
| Howard Hinnant | b0bfd9b | 2012-02-15 00:41:34 | [diff] [blame] | 903 | __alloc_traits::__construct_backward(this->__alloc(), this->__begin_, __p, __v.__begin_); | 
|  | 904 | __alloc_traits::__construct_forward(this->__alloc(), __p, this->__end_, __v.__end_); | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 905 | _VSTD::swap(this->__begin_, __v.__begin_); | 
|  | 906 | _VSTD::swap(this->__end_, __v.__end_); | 
|  | 907 | _VSTD::swap(this->__end_cap(), __v.__end_cap()); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 908 | __v.__first_ = __v.__begin_; | 
| Marshall Clow | 1f50f2d | 2014-05-08 14:14:06 | [diff] [blame] | 909 | __annotate_new(size()); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 910 | __invalidate_all_iterators(); | 
|  | 911 | return __r; | 
|  | 912 | } | 
|  | 913 |  | 
|  | 914 | // Allocate space for __n objects | 
|  | 915 | // throws length_error if __n > max_size() | 
|  | 916 | // throws (probably bad_alloc) if memory run out | 
|  | 917 | // Precondition: __begin_ == __end_ == __end_cap() == 0 | 
|  | 918 | // Precondition: __n > 0 | 
|  | 919 | // Postcondition: capacity() == __n | 
|  | 920 | // Postcondition: size() == 0 | 
|  | 921 | template <class _Tp, class _Allocator> | 
|  | 922 | void | 
|  | 923 | vector<_Tp, _Allocator>::allocate(size_type __n) | 
|  | 924 | { | 
|  | 925 | if (__n > max_size()) | 
|  | 926 | this->__throw_length_error(); | 
|  | 927 | this->__begin_ = this->__end_ = __alloc_traits::allocate(this->__alloc(), __n); | 
|  | 928 | this->__end_cap() = this->__begin_ + __n; | 
| Marshall Clow | 1f50f2d | 2014-05-08 14:14:06 | [diff] [blame] | 929 | __annotate_new(0); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 930 | } | 
|  | 931 |  | 
|  | 932 | template <class _Tp, class _Allocator> | 
|  | 933 | void | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 934 | vector<_Tp, _Allocator>::deallocate() _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 935 | { | 
| Howard Hinnant | 2c39cbe | 2013-06-27 19:35:32 | [diff] [blame] | 936 | if (this->__begin_ != nullptr) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 937 | { | 
|  | 938 | clear(); | 
|  | 939 | __alloc_traits::deallocate(this->__alloc(), this->__begin_, capacity()); | 
| Howard Hinnant | 2c39cbe | 2013-06-27 19:35:32 | [diff] [blame] | 940 | this->__begin_ = this->__end_ = this->__end_cap() = nullptr; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 941 | } | 
|  | 942 | } | 
|  | 943 |  | 
|  | 944 | template <class _Tp, class _Allocator> | 
|  | 945 | typename vector<_Tp, _Allocator>::size_type | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 946 | vector<_Tp, _Allocator>::max_size() const _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 947 | { | 
| Eric Fiselier | ef3060e | 2016-11-23 01:18:56 | [diff] [blame] | 948 | return _VSTD::min<size_type>(__alloc_traits::max_size(this->__alloc()), | 
|  | 949 | numeric_limits<difference_type>::max()); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 950 | } | 
|  | 951 |  | 
|  | 952 | // Precondition: __new_size > capacity() | 
|  | 953 | template <class _Tp, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 | [diff] [blame] | 954 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 955 | typename vector<_Tp, _Allocator>::size_type | 
|  | 956 | vector<_Tp, _Allocator>::__recommend(size_type __new_size) const | 
|  | 957 | { | 
|  | 958 | const size_type __ms = max_size(); | 
|  | 959 | if (__new_size > __ms) | 
|  | 960 | this->__throw_length_error(); | 
|  | 961 | const size_type __cap = capacity(); | 
|  | 962 | if (__cap >= __ms / 2) | 
|  | 963 | return __ms; | 
| Sean Hunt | 110b8bf | 2011-07-29 23:31:58 | [diff] [blame] | 964 | return _VSTD::max<size_type>(2*__cap, __new_size); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 965 | } | 
|  | 966 |  | 
|  | 967 | // Default constructs __n objects starting at __end_ | 
|  | 968 | // throws if construction throws | 
|  | 969 | // Precondition: __n > 0 | 
|  | 970 | // Precondition: size() + __n <= capacity() | 
|  | 971 | // Postcondition: size() == size() + __n | 
|  | 972 | template <class _Tp, class _Allocator> | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 973 | void | 
|  | 974 | vector<_Tp, _Allocator>::__construct_at_end(size_type __n) | 
|  | 975 | { | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 976 | allocator_type& __a = this->__alloc(); | 
|  | 977 | do | 
|  | 978 | { | 
| Kostya Serebryany | 497f912 | 2014-09-02 23:43:38 | [diff] [blame] | 979 | __RAII_IncreaseAnnotator __annotator(*this); | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 980 | __alloc_traits::construct(__a, _VSTD::__to_raw_pointer(this->__end_)); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 981 | ++this->__end_; | 
|  | 982 | --__n; | 
| Kostya Serebryany | 497f912 | 2014-09-02 23:43:38 | [diff] [blame] | 983 | __annotator.__done(); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 984 | } while (__n > 0); | 
|  | 985 | } | 
|  | 986 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 987 | // Copy constructs __n objects starting at __end_ from __x | 
|  | 988 | // throws if construction throws | 
|  | 989 | // Precondition: __n > 0 | 
|  | 990 | // Precondition: size() + __n <= capacity() | 
|  | 991 | // Postcondition: size() == old size() + __n | 
|  | 992 | // Postcondition: [i] == __x for all i in [size() - __n, __n) | 
|  | 993 | template <class _Tp, class _Allocator> | 
| Evgeniy Stepanov | a3b25f8 | 2015-11-07 01:22:13 | [diff] [blame] | 994 | inline | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 995 | void | 
|  | 996 | vector<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x) | 
|  | 997 | { | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 998 | allocator_type& __a = this->__alloc(); | 
|  | 999 | do | 
|  | 1000 | { | 
| Kostya Serebryany | 497f912 | 2014-09-02 23:43:38 | [diff] [blame] | 1001 | __RAII_IncreaseAnnotator __annotator(*this); | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 1002 | __alloc_traits::construct(__a, _VSTD::__to_raw_pointer(this->__end_), __x); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1003 | ++this->__end_; | 
|  | 1004 | --__n; | 
| Kostya Serebryany | 497f912 | 2014-09-02 23:43:38 | [diff] [blame] | 1005 | __annotator.__done(); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1006 | } while (__n > 0); | 
|  | 1007 | } | 
|  | 1008 |  | 
|  | 1009 | template <class _Tp, class _Allocator> | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1010 | template <class _ForwardIterator> | 
|  | 1011 | typename enable_if | 
|  | 1012 | < | 
|  | 1013 | __is_forward_iterator<_ForwardIterator>::value, | 
|  | 1014 | void | 
|  | 1015 | >::type | 
| Eric Fiselier | 088ed9f | 2015-03-31 16:54:19 | [diff] [blame] | 1016 | vector<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last, size_type __n) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1017 | { | 
|  | 1018 | allocator_type& __a = this->__alloc(); | 
| Eric Fiselier | 088ed9f | 2015-03-31 16:54:19 | [diff] [blame] | 1019 | __RAII_IncreaseAnnotator __annotator(*this, __n); | 
|  | 1020 | __alloc_traits::__construct_range_forward(__a, __first, __last, this->__end_); | 
|  | 1021 | __annotator.__done(); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1022 | } | 
|  | 1023 |  | 
|  | 1024 | // Default constructs __n objects starting at __end_ | 
|  | 1025 | // throws if construction throws | 
|  | 1026 | // Postcondition: size() == size() + __n | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 1027 | // Exception safety: strong. | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1028 | template <class _Tp, class _Allocator> | 
|  | 1029 | void | 
|  | 1030 | vector<_Tp, _Allocator>::__append(size_type __n) | 
|  | 1031 | { | 
|  | 1032 | if (static_cast<size_type>(this->__end_cap() - this->__end_) >= __n) | 
|  | 1033 | this->__construct_at_end(__n); | 
|  | 1034 | else | 
|  | 1035 | { | 
|  | 1036 | allocator_type& __a = this->__alloc(); | 
|  | 1037 | __split_buffer<value_type, allocator_type&> __v(__recommend(size() + __n), size(), __a); | 
|  | 1038 | __v.__construct_at_end(__n); | 
|  | 1039 | __swap_out_circular_buffer(__v); | 
|  | 1040 | } | 
|  | 1041 | } | 
|  | 1042 |  | 
|  | 1043 | // Default constructs __n objects starting at __end_ | 
|  | 1044 | // throws if construction throws | 
|  | 1045 | // Postcondition: size() == size() + __n | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 1046 | // Exception safety: strong. | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1047 | template <class _Tp, class _Allocator> | 
|  | 1048 | void | 
|  | 1049 | vector<_Tp, _Allocator>::__append(size_type __n, const_reference __x) | 
|  | 1050 | { | 
|  | 1051 | if (static_cast<size_type>(this->__end_cap() - this->__end_) >= __n) | 
|  | 1052 | this->__construct_at_end(__n, __x); | 
|  | 1053 | else | 
|  | 1054 | { | 
|  | 1055 | allocator_type& __a = this->__alloc(); | 
|  | 1056 | __split_buffer<value_type, allocator_type&> __v(__recommend(size() + __n), size(), __a); | 
|  | 1057 | __v.__construct_at_end(__n, __x); | 
|  | 1058 | __swap_out_circular_buffer(__v); | 
|  | 1059 | } | 
|  | 1060 | } | 
|  | 1061 |  | 
|  | 1062 | template <class _Tp, class _Allocator> | 
|  | 1063 | vector<_Tp, _Allocator>::vector(size_type __n) | 
|  | 1064 | { | 
| Howard Hinnant | 0442b12 | 2011-09-16 18:41:29 | [diff] [blame] | 1065 | #if _LIBCPP_DEBUG_LEVEL >= 2 | 
|  | 1066 | __get_db()->__insert_c(this); | 
|  | 1067 | #endif | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1068 | if (__n > 0) | 
|  | 1069 | { | 
|  | 1070 | allocate(__n); | 
|  | 1071 | __construct_at_end(__n); | 
|  | 1072 | } | 
|  | 1073 | } | 
|  | 1074 |  | 
| Marshall Clow | a49a2c9 | 2013-09-14 00:47:59 | [diff] [blame] | 1075 | #if _LIBCPP_STD_VER > 11 | 
|  | 1076 | template <class _Tp, class _Allocator> | 
|  | 1077 | vector<_Tp, _Allocator>::vector(size_type __n, const allocator_type& __a) | 
|  | 1078 | : __base(__a) | 
|  | 1079 | { | 
|  | 1080 | #if _LIBCPP_DEBUG_LEVEL >= 2 | 
|  | 1081 | __get_db()->__insert_c(this); | 
|  | 1082 | #endif | 
|  | 1083 | if (__n > 0) | 
|  | 1084 | { | 
|  | 1085 | allocate(__n); | 
|  | 1086 | __construct_at_end(__n); | 
|  | 1087 | } | 
|  | 1088 | } | 
|  | 1089 | #endif | 
|  | 1090 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1091 | template <class _Tp, class _Allocator> | 
|  | 1092 | vector<_Tp, _Allocator>::vector(size_type __n, const_reference __x) | 
|  | 1093 | { | 
| Howard Hinnant | 0442b12 | 2011-09-16 18:41:29 | [diff] [blame] | 1094 | #if _LIBCPP_DEBUG_LEVEL >= 2 | 
|  | 1095 | __get_db()->__insert_c(this); | 
|  | 1096 | #endif | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1097 | if (__n > 0) | 
|  | 1098 | { | 
|  | 1099 | allocate(__n); | 
|  | 1100 | __construct_at_end(__n, __x); | 
|  | 1101 | } | 
|  | 1102 | } | 
|  | 1103 |  | 
|  | 1104 | template <class _Tp, class _Allocator> | 
|  | 1105 | vector<_Tp, _Allocator>::vector(size_type __n, const_reference __x, const allocator_type& __a) | 
|  | 1106 | : __base(__a) | 
|  | 1107 | { | 
| Howard Hinnant | 0442b12 | 2011-09-16 18:41:29 | [diff] [blame] | 1108 | #if _LIBCPP_DEBUG_LEVEL >= 2 | 
|  | 1109 | __get_db()->__insert_c(this); | 
|  | 1110 | #endif | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1111 | if (__n > 0) | 
|  | 1112 | { | 
|  | 1113 | allocate(__n); | 
|  | 1114 | __construct_at_end(__n, __x); | 
|  | 1115 | } | 
|  | 1116 | } | 
|  | 1117 |  | 
|  | 1118 | template <class _Tp, class _Allocator> | 
|  | 1119 | template <class _InputIterator> | 
| Howard Hinnant | de589f2 | 2013-09-21 21:13:54 | [diff] [blame] | 1120 | vector<_Tp, _Allocator>::vector(_InputIterator __first, | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1121 | typename enable_if<__is_input_iterator <_InputIterator>::value && | 
| Howard Hinnant | 742fecb | 2013-03-28 17:44:32 | [diff] [blame] | 1122 | !__is_forward_iterator<_InputIterator>::value && | 
|  | 1123 | is_constructible< | 
|  | 1124 | value_type, | 
| Howard Hinnant | de589f2 | 2013-09-21 21:13:54 | [diff] [blame] | 1125 | typename iterator_traits<_InputIterator>::reference>::value, | 
|  | 1126 | _InputIterator>::type __last) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1127 | { | 
| Howard Hinnant | abe2628 | 2011-09-16 17:29:17 | [diff] [blame] | 1128 | #if _LIBCPP_DEBUG_LEVEL >= 2 | 
| Howard Hinnant | 7a563db | 2011-09-14 18:33:51 | [diff] [blame] | 1129 | __get_db()->__insert_c(this); | 
|  | 1130 | #endif | 
| Howard Hinnant | 0442b12 | 2011-09-16 18:41:29 | [diff] [blame] | 1131 | for (; __first != __last; ++__first) | 
|  | 1132 | push_back(*__first); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1133 | } | 
|  | 1134 |  | 
|  | 1135 | template <class _Tp, class _Allocator> | 
|  | 1136 | template <class _InputIterator> | 
|  | 1137 | vector<_Tp, _Allocator>::vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a, | 
|  | 1138 | typename enable_if<__is_input_iterator <_InputIterator>::value && | 
| Howard Hinnant | 742fecb | 2013-03-28 17:44:32 | [diff] [blame] | 1139 | !__is_forward_iterator<_InputIterator>::value && | 
|  | 1140 | is_constructible< | 
|  | 1141 | value_type, | 
|  | 1142 | typename iterator_traits<_InputIterator>::reference>::value>::type*) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1143 | : __base(__a) | 
|  | 1144 | { | 
| Howard Hinnant | abe2628 | 2011-09-16 17:29:17 | [diff] [blame] | 1145 | #if _LIBCPP_DEBUG_LEVEL >= 2 | 
| Howard Hinnant | 7a563db | 2011-09-14 18:33:51 | [diff] [blame] | 1146 | __get_db()->__insert_c(this); | 
|  | 1147 | #endif | 
| Howard Hinnant | 0442b12 | 2011-09-16 18:41:29 | [diff] [blame] | 1148 | for (; __first != __last; ++__first) | 
|  | 1149 | push_back(*__first); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1150 | } | 
|  | 1151 |  | 
|  | 1152 | template <class _Tp, class _Allocator> | 
|  | 1153 | template <class _ForwardIterator> | 
| Howard Hinnant | de589f2 | 2013-09-21 21:13:54 | [diff] [blame] | 1154 | vector<_Tp, _Allocator>::vector(_ForwardIterator __first, | 
| Howard Hinnant | 742fecb | 2013-03-28 17:44:32 | [diff] [blame] | 1155 | typename enable_if<__is_forward_iterator<_ForwardIterator>::value && | 
|  | 1156 | is_constructible< | 
|  | 1157 | value_type, | 
| Howard Hinnant | de589f2 | 2013-09-21 21:13:54 | [diff] [blame] | 1158 | typename iterator_traits<_ForwardIterator>::reference>::value, | 
|  | 1159 | _ForwardIterator>::type __last) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1160 | { | 
| Howard Hinnant | 0442b12 | 2011-09-16 18:41:29 | [diff] [blame] | 1161 | #if _LIBCPP_DEBUG_LEVEL >= 2 | 
|  | 1162 | __get_db()->__insert_c(this); | 
|  | 1163 | #endif | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 1164 | size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last)); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1165 | if (__n > 0) | 
|  | 1166 | { | 
|  | 1167 | allocate(__n); | 
| Eric Fiselier | 088ed9f | 2015-03-31 16:54:19 | [diff] [blame] | 1168 | __construct_at_end(__first, __last, __n); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1169 | } | 
|  | 1170 | } | 
|  | 1171 |  | 
|  | 1172 | template <class _Tp, class _Allocator> | 
|  | 1173 | template <class _ForwardIterator> | 
|  | 1174 | vector<_Tp, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a, | 
| Howard Hinnant | 742fecb | 2013-03-28 17:44:32 | [diff] [blame] | 1175 | typename enable_if<__is_forward_iterator<_ForwardIterator>::value && | 
|  | 1176 | is_constructible< | 
|  | 1177 | value_type, | 
|  | 1178 | typename iterator_traits<_ForwardIterator>::reference>::value>::type*) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1179 | : __base(__a) | 
|  | 1180 | { | 
| Howard Hinnant | 0442b12 | 2011-09-16 18:41:29 | [diff] [blame] | 1181 | #if _LIBCPP_DEBUG_LEVEL >= 2 | 
|  | 1182 | __get_db()->__insert_c(this); | 
|  | 1183 | #endif | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 1184 | size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last)); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1185 | if (__n > 0) | 
|  | 1186 | { | 
|  | 1187 | allocate(__n); | 
| Eric Fiselier | 088ed9f | 2015-03-31 16:54:19 | [diff] [blame] | 1188 | __construct_at_end(__first, __last, __n); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1189 | } | 
|  | 1190 | } | 
|  | 1191 |  | 
|  | 1192 | template <class _Tp, class _Allocator> | 
|  | 1193 | vector<_Tp, _Allocator>::vector(const vector& __x) | 
|  | 1194 | : __base(__alloc_traits::select_on_container_copy_construction(__x.__alloc())) | 
|  | 1195 | { | 
| Howard Hinnant | 0442b12 | 2011-09-16 18:41:29 | [diff] [blame] | 1196 | #if _LIBCPP_DEBUG_LEVEL >= 2 | 
|  | 1197 | __get_db()->__insert_c(this); | 
|  | 1198 | #endif | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1199 | size_type __n = __x.size(); | 
|  | 1200 | if (__n > 0) | 
|  | 1201 | { | 
|  | 1202 | allocate(__n); | 
| Eric Fiselier | 088ed9f | 2015-03-31 16:54:19 | [diff] [blame] | 1203 | __construct_at_end(__x.__begin_, __x.__end_, __n); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1204 | } | 
|  | 1205 | } | 
|  | 1206 |  | 
|  | 1207 | template <class _Tp, class _Allocator> | 
|  | 1208 | vector<_Tp, _Allocator>::vector(const vector& __x, const allocator_type& __a) | 
|  | 1209 | : __base(__a) | 
|  | 1210 | { | 
| Howard Hinnant | 0442b12 | 2011-09-16 18:41:29 | [diff] [blame] | 1211 | #if _LIBCPP_DEBUG_LEVEL >= 2 | 
|  | 1212 | __get_db()->__insert_c(this); | 
|  | 1213 | #endif | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1214 | size_type __n = __x.size(); | 
|  | 1215 | if (__n > 0) | 
|  | 1216 | { | 
|  | 1217 | allocate(__n); | 
| Eric Fiselier | 088ed9f | 2015-03-31 16:54:19 | [diff] [blame] | 1218 | __construct_at_end(__x.__begin_, __x.__end_, __n); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1219 | } | 
|  | 1220 | } | 
|  | 1221 |  | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 | [diff] [blame] | 1222 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1223 |  | 
|  | 1224 | template <class _Tp, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 | [diff] [blame] | 1225 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1226 | vector<_Tp, _Allocator>::vector(vector&& __x) | 
| Marshall Clow | 119ed47 | 2015-07-14 14:46:32 | [diff] [blame] | 1227 | #if _LIBCPP_STD_VER > 14 | 
|  | 1228 | _NOEXCEPT | 
|  | 1229 | #else | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 1230 | _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value) | 
| Marshall Clow | 119ed47 | 2015-07-14 14:46:32 | [diff] [blame] | 1231 | #endif | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 1232 | : __base(_VSTD::move(__x.__alloc())) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1233 | { | 
| Howard Hinnant | abe2628 | 2011-09-16 17:29:17 | [diff] [blame] | 1234 | #if _LIBCPP_DEBUG_LEVEL >= 2 | 
| Howard Hinnant | 7a563db | 2011-09-14 18:33:51 | [diff] [blame] | 1235 | __get_db()->__insert_c(this); | 
| Howard Hinnant | e6125bd | 2011-09-19 16:34:29 | [diff] [blame] | 1236 | __get_db()->swap(this, &__x); | 
| Howard Hinnant | 7a563db | 2011-09-14 18:33:51 | [diff] [blame] | 1237 | #endif | 
| Howard Hinnant | 0442b12 | 2011-09-16 18:41:29 | [diff] [blame] | 1238 | this->__begin_ = __x.__begin_; | 
|  | 1239 | this->__end_ = __x.__end_; | 
|  | 1240 | this->__end_cap() = __x.__end_cap(); | 
| Howard Hinnant | 2c39cbe | 2013-06-27 19:35:32 | [diff] [blame] | 1241 | __x.__begin_ = __x.__end_ = __x.__end_cap() = nullptr; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1242 | } | 
|  | 1243 |  | 
|  | 1244 | template <class _Tp, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 | [diff] [blame] | 1245 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1246 | vector<_Tp, _Allocator>::vector(vector&& __x, const allocator_type& __a) | 
|  | 1247 | : __base(__a) | 
|  | 1248 | { | 
| Howard Hinnant | 0442b12 | 2011-09-16 18:41:29 | [diff] [blame] | 1249 | #if _LIBCPP_DEBUG_LEVEL >= 2 | 
|  | 1250 | __get_db()->__insert_c(this); | 
|  | 1251 | #endif | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1252 | if (__a == __x.__alloc()) | 
|  | 1253 | { | 
|  | 1254 | this->__begin_ = __x.__begin_; | 
|  | 1255 | this->__end_ = __x.__end_; | 
|  | 1256 | this->__end_cap() = __x.__end_cap(); | 
|  | 1257 | __x.__begin_ = __x.__end_ = __x.__end_cap() = nullptr; | 
| Howard Hinnant | e6125bd | 2011-09-19 16:34:29 | [diff] [blame] | 1258 | #if _LIBCPP_DEBUG_LEVEL >= 2 | 
|  | 1259 | __get_db()->swap(this, &__x); | 
|  | 1260 | #endif | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1261 | } | 
|  | 1262 | else | 
|  | 1263 | { | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 | [diff] [blame] | 1264 | typedef move_iterator<iterator> _Ip; | 
|  | 1265 | assign(_Ip(__x.begin()), _Ip(__x.end())); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1266 | } | 
|  | 1267 | } | 
|  | 1268 |  | 
| Howard Hinnant | e3e3291 | 2011-08-12 21:56:02 | [diff] [blame] | 1269 | #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS | 
|  | 1270 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1271 | template <class _Tp, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 | [diff] [blame] | 1272 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1273 | vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il) | 
|  | 1274 | { | 
| Howard Hinnant | 0442b12 | 2011-09-16 18:41:29 | [diff] [blame] | 1275 | #if _LIBCPP_DEBUG_LEVEL >= 2 | 
|  | 1276 | __get_db()->__insert_c(this); | 
|  | 1277 | #endif | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1278 | if (__il.size() > 0) | 
|  | 1279 | { | 
|  | 1280 | allocate(__il.size()); | 
| Eric Fiselier | 088ed9f | 2015-03-31 16:54:19 | [diff] [blame] | 1281 | __construct_at_end(__il.begin(), __il.end(), __il.size()); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1282 | } | 
|  | 1283 | } | 
|  | 1284 |  | 
|  | 1285 | template <class _Tp, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 | [diff] [blame] | 1286 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1287 | vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il, const allocator_type& __a) | 
|  | 1288 | : __base(__a) | 
|  | 1289 | { | 
| Howard Hinnant | 0442b12 | 2011-09-16 18:41:29 | [diff] [blame] | 1290 | #if _LIBCPP_DEBUG_LEVEL >= 2 | 
|  | 1291 | __get_db()->__insert_c(this); | 
|  | 1292 | #endif | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1293 | if (__il.size() > 0) | 
|  | 1294 | { | 
|  | 1295 | allocate(__il.size()); | 
| Eric Fiselier | 088ed9f | 2015-03-31 16:54:19 | [diff] [blame] | 1296 | __construct_at_end(__il.begin(), __il.end(), __il.size()); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1297 | } | 
|  | 1298 | } | 
|  | 1299 |  | 
| Howard Hinnant | e3e3291 | 2011-08-12 21:56:02 | [diff] [blame] | 1300 | #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS | 
|  | 1301 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1302 | template <class _Tp, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 | [diff] [blame] | 1303 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1304 | vector<_Tp, _Allocator>& | 
|  | 1305 | vector<_Tp, _Allocator>::operator=(vector&& __x) | 
| Marshall Clow | af961ed | 2015-08-18 18:57:00 | [diff] [blame] | 1306 | _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value)) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1307 | { | 
|  | 1308 | __move_assign(__x, integral_constant<bool, | 
|  | 1309 | __alloc_traits::propagate_on_container_move_assignment::value>()); | 
|  | 1310 | return *this; | 
|  | 1311 | } | 
|  | 1312 |  | 
|  | 1313 | template <class _Tp, class _Allocator> | 
|  | 1314 | void | 
|  | 1315 | vector<_Tp, _Allocator>::__move_assign(vector& __c, false_type) | 
| Marshall Clow | af961ed | 2015-08-18 18:57:00 | [diff] [blame] | 1316 | _NOEXCEPT_(__alloc_traits::is_always_equal::value) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1317 | { | 
|  | 1318 | if (__base::__alloc() != __c.__alloc()) | 
|  | 1319 | { | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 | [diff] [blame] | 1320 | typedef move_iterator<iterator> _Ip; | 
|  | 1321 | assign(_Ip(__c.begin()), _Ip(__c.end())); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1322 | } | 
|  | 1323 | else | 
|  | 1324 | __move_assign(__c, true_type()); | 
|  | 1325 | } | 
|  | 1326 |  | 
|  | 1327 | template <class _Tp, class _Allocator> | 
|  | 1328 | void | 
|  | 1329 | vector<_Tp, _Allocator>::__move_assign(vector& __c, true_type) | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 1330 | _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1331 | { | 
|  | 1332 | deallocate(); | 
| Marshall Clow | 3c2eac6 | 2014-07-21 15:11:13 | [diff] [blame] | 1333 | __base::__move_assign_alloc(__c); // this can throw | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1334 | this->__begin_ = __c.__begin_; | 
|  | 1335 | this->__end_ = __c.__end_; | 
|  | 1336 | this->__end_cap() = __c.__end_cap(); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1337 | __c.__begin_ = __c.__end_ = __c.__end_cap() = nullptr; | 
| Howard Hinnant | e6125bd | 2011-09-19 16:34:29 | [diff] [blame] | 1338 | #if _LIBCPP_DEBUG_LEVEL >= 2 | 
|  | 1339 | __get_db()->swap(this, &__c); | 
|  | 1340 | #endif | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1341 | } | 
|  | 1342 |  | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 | [diff] [blame] | 1343 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1344 |  | 
|  | 1345 | template <class _Tp, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 | [diff] [blame] | 1346 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1347 | vector<_Tp, _Allocator>& | 
|  | 1348 | vector<_Tp, _Allocator>::operator=(const vector& __x) | 
|  | 1349 | { | 
|  | 1350 | if (this != &__x) | 
|  | 1351 | { | 
|  | 1352 | __base::__copy_assign_alloc(__x); | 
|  | 1353 | assign(__x.__begin_, __x.__end_); | 
|  | 1354 | } | 
|  | 1355 | return *this; | 
|  | 1356 | } | 
|  | 1357 |  | 
|  | 1358 | template <class _Tp, class _Allocator> | 
|  | 1359 | template <class _InputIterator> | 
|  | 1360 | typename enable_if | 
|  | 1361 | < | 
|  | 1362 | __is_input_iterator <_InputIterator>::value && | 
| Howard Hinnant | 742fecb | 2013-03-28 17:44:32 | [diff] [blame] | 1363 | !__is_forward_iterator<_InputIterator>::value && | 
|  | 1364 | is_constructible< | 
|  | 1365 | _Tp, | 
|  | 1366 | typename iterator_traits<_InputIterator>::reference>::value, | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1367 | void | 
|  | 1368 | >::type | 
|  | 1369 | vector<_Tp, _Allocator>::assign(_InputIterator __first, _InputIterator __last) | 
|  | 1370 | { | 
|  | 1371 | clear(); | 
|  | 1372 | for (; __first != __last; ++__first) | 
|  | 1373 | push_back(*__first); | 
|  | 1374 | } | 
|  | 1375 |  | 
|  | 1376 | template <class _Tp, class _Allocator> | 
|  | 1377 | template <class _ForwardIterator> | 
|  | 1378 | typename enable_if | 
|  | 1379 | < | 
| Howard Hinnant | 742fecb | 2013-03-28 17:44:32 | [diff] [blame] | 1380 | __is_forward_iterator<_ForwardIterator>::value && | 
|  | 1381 | is_constructible< | 
|  | 1382 | _Tp, | 
|  | 1383 | typename iterator_traits<_ForwardIterator>::reference>::value, | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1384 | void | 
|  | 1385 | >::type | 
|  | 1386 | vector<_Tp, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __last) | 
|  | 1387 | { | 
| Eric Fiselier | 088ed9f | 2015-03-31 16:54:19 | [diff] [blame] | 1388 | size_type __new_size = static_cast<size_type>(_VSTD::distance(__first, __last)); | 
|  | 1389 | if (__new_size <= capacity()) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1390 | { | 
|  | 1391 | _ForwardIterator __mid = __last; | 
|  | 1392 | bool __growing = false; | 
| Eric Fiselier | 088ed9f | 2015-03-31 16:54:19 | [diff] [blame] | 1393 | if (__new_size > size()) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1394 | { | 
|  | 1395 | __growing = true; | 
|  | 1396 | __mid = __first; | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 1397 | _VSTD::advance(__mid, size()); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1398 | } | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 1399 | pointer __m = _VSTD::copy(__first, __mid, this->__begin_); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1400 | if (__growing) | 
| Eric Fiselier | 088ed9f | 2015-03-31 16:54:19 | [diff] [blame] | 1401 | __construct_at_end(__mid, __last, __new_size - size()); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1402 | else | 
|  | 1403 | this->__destruct_at_end(__m); | 
|  | 1404 | } | 
|  | 1405 | else | 
|  | 1406 | { | 
|  | 1407 | deallocate(); | 
| Eric Fiselier | 088ed9f | 2015-03-31 16:54:19 | [diff] [blame] | 1408 | allocate(__recommend(__new_size)); | 
|  | 1409 | __construct_at_end(__first, __last, __new_size); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1410 | } | 
| Eric Fiselier | fb34238 | 2016-12-28 06:06:09 | [diff] [blame] | 1411 | __invalidate_all_iterators(); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1412 | } | 
|  | 1413 |  | 
|  | 1414 | template <class _Tp, class _Allocator> | 
|  | 1415 | void | 
|  | 1416 | vector<_Tp, _Allocator>::assign(size_type __n, const_reference __u) | 
|  | 1417 | { | 
|  | 1418 | if (__n <= capacity()) | 
|  | 1419 | { | 
|  | 1420 | size_type __s = size(); | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 1421 | _VSTD::fill_n(this->__begin_, _VSTD::min(__n, __s), __u); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1422 | if (__n > __s) | 
|  | 1423 | __construct_at_end(__n - __s, __u); | 
|  | 1424 | else | 
| Howard Hinnant | adff489 | 2010-05-24 17:49:41 | [diff] [blame] | 1425 | this->__destruct_at_end(this->__begin_ + __n); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1426 | } | 
|  | 1427 | else | 
|  | 1428 | { | 
|  | 1429 | deallocate(); | 
|  | 1430 | allocate(__recommend(static_cast<size_type>(__n))); | 
|  | 1431 | __construct_at_end(__n, __u); | 
|  | 1432 | } | 
| Eric Fiselier | fb34238 | 2016-12-28 06:06:09 | [diff] [blame] | 1433 | __invalidate_all_iterators(); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1434 | } | 
|  | 1435 |  | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 1436 | template <class _Tp, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 | [diff] [blame] | 1437 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1438 | typename vector<_Tp, _Allocator>::iterator | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 1439 | vector<_Tp, _Allocator>::__make_iter(pointer __p) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1440 | { | 
| Howard Hinnant | abe2628 | 2011-09-16 17:29:17 | [diff] [blame] | 1441 | #if _LIBCPP_DEBUG_LEVEL >= 2 | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1442 | return iterator(this, __p); | 
|  | 1443 | #else | 
|  | 1444 | return iterator(__p); | 
|  | 1445 | #endif | 
|  | 1446 | } | 
|  | 1447 |  | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 1448 | template <class _Tp, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 | [diff] [blame] | 1449 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1450 | typename vector<_Tp, _Allocator>::const_iterator | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 1451 | vector<_Tp, _Allocator>::__make_iter(const_pointer __p) const _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1452 | { | 
| Howard Hinnant | abe2628 | 2011-09-16 17:29:17 | [diff] [blame] | 1453 | #if _LIBCPP_DEBUG_LEVEL >= 2 | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1454 | return const_iterator(this, __p); | 
|  | 1455 | #else | 
|  | 1456 | return const_iterator(__p); | 
|  | 1457 | #endif | 
|  | 1458 | } | 
|  | 1459 |  | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 1460 | template <class _Tp, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 | [diff] [blame] | 1461 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1462 | typename vector<_Tp, _Allocator>::iterator | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 1463 | vector<_Tp, _Allocator>::begin() _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1464 | { | 
|  | 1465 | return __make_iter(this->__begin_); | 
|  | 1466 | } | 
|  | 1467 |  | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 1468 | template <class _Tp, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 | [diff] [blame] | 1469 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1470 | typename vector<_Tp, _Allocator>::const_iterator | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 1471 | vector<_Tp, _Allocator>::begin() const _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1472 | { | 
|  | 1473 | return __make_iter(this->__begin_); | 
|  | 1474 | } | 
|  | 1475 |  | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 1476 | template <class _Tp, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 | [diff] [blame] | 1477 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1478 | typename vector<_Tp, _Allocator>::iterator | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 1479 | vector<_Tp, _Allocator>::end() _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1480 | { | 
|  | 1481 | return __make_iter(this->__end_); | 
|  | 1482 | } | 
|  | 1483 |  | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 1484 | template <class _Tp, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 | [diff] [blame] | 1485 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1486 | typename vector<_Tp, _Allocator>::const_iterator | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 1487 | vector<_Tp, _Allocator>::end() const _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1488 | { | 
|  | 1489 | return __make_iter(this->__end_); | 
|  | 1490 | } | 
|  | 1491 |  | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 1492 | template <class _Tp, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 | [diff] [blame] | 1493 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1494 | typename vector<_Tp, _Allocator>::reference | 
|  | 1495 | vector<_Tp, _Allocator>::operator[](size_type __n) | 
|  | 1496 | { | 
| Howard Hinnant | 7a563db | 2011-09-14 18:33:51 | [diff] [blame] | 1497 | _LIBCPP_ASSERT(__n < size(), "vector[] index out of bounds"); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1498 | return this->__begin_[__n]; | 
|  | 1499 | } | 
|  | 1500 |  | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 1501 | template <class _Tp, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 | [diff] [blame] | 1502 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1503 | typename vector<_Tp, _Allocator>::const_reference | 
|  | 1504 | vector<_Tp, _Allocator>::operator[](size_type __n) const | 
|  | 1505 | { | 
| Howard Hinnant | 7a563db | 2011-09-14 18:33:51 | [diff] [blame] | 1506 | _LIBCPP_ASSERT(__n < size(), "vector[] index out of bounds"); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1507 | return this->__begin_[__n]; | 
|  | 1508 | } | 
|  | 1509 |  | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 1510 | template <class _Tp, class _Allocator> | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1511 | typename vector<_Tp, _Allocator>::reference | 
|  | 1512 | vector<_Tp, _Allocator>::at(size_type __n) | 
|  | 1513 | { | 
|  | 1514 | if (__n >= size()) | 
|  | 1515 | this->__throw_out_of_range(); | 
|  | 1516 | return this->__begin_[__n]; | 
|  | 1517 | } | 
|  | 1518 |  | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 1519 | template <class _Tp, class _Allocator> | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1520 | typename vector<_Tp, _Allocator>::const_reference | 
|  | 1521 | vector<_Tp, _Allocator>::at(size_type __n) const | 
|  | 1522 | { | 
|  | 1523 | if (__n >= size()) | 
|  | 1524 | this->__throw_out_of_range(); | 
|  | 1525 | return this->__begin_[__n]; | 
|  | 1526 | } | 
|  | 1527 |  | 
|  | 1528 | template <class _Tp, class _Allocator> | 
|  | 1529 | void | 
|  | 1530 | vector<_Tp, _Allocator>::reserve(size_type __n) | 
|  | 1531 | { | 
|  | 1532 | if (__n > capacity()) | 
|  | 1533 | { | 
|  | 1534 | allocator_type& __a = this->__alloc(); | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 1535 | __split_buffer<value_type, allocator_type&> __v(__n, size(), __a); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1536 | __swap_out_circular_buffer(__v); | 
|  | 1537 | } | 
|  | 1538 | } | 
|  | 1539 |  | 
|  | 1540 | template <class _Tp, class _Allocator> | 
|  | 1541 | void | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 1542 | vector<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1543 | { | 
|  | 1544 | if (capacity() > size()) | 
|  | 1545 | { | 
|  | 1546 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
|  | 1547 | try | 
|  | 1548 | { | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 1549 | #endif // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1550 | allocator_type& __a = this->__alloc(); | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 1551 | __split_buffer<value_type, allocator_type&> __v(size(), size(), __a); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1552 | __swap_out_circular_buffer(__v); | 
|  | 1553 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
|  | 1554 | } | 
|  | 1555 | catch (...) | 
|  | 1556 | { | 
|  | 1557 | } | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 1558 | #endif // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1559 | } | 
|  | 1560 | } | 
|  | 1561 |  | 
|  | 1562 | template <class _Tp, class _Allocator> | 
| Howard Hinnant | b0bfd9b | 2012-02-15 00:41:34 | [diff] [blame] | 1563 | template <class _Up> | 
|  | 1564 | void | 
|  | 1565 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
|  | 1566 | vector<_Tp, _Allocator>::__push_back_slow_path(_Up&& __x) | 
|  | 1567 | #else | 
|  | 1568 | vector<_Tp, _Allocator>::__push_back_slow_path(_Up& __x) | 
|  | 1569 | #endif | 
|  | 1570 | { | 
|  | 1571 | allocator_type& __a = this->__alloc(); | 
|  | 1572 | __split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), size(), __a); | 
|  | 1573 | // __v.push_back(_VSTD::forward<_Up>(__x)); | 
| Howard Hinnant | f619e23 | 2013-01-11 20:36:59 | [diff] [blame] | 1574 | __alloc_traits::construct(__a, _VSTD::__to_raw_pointer(__v.__end_), _VSTD::forward<_Up>(__x)); | 
|  | 1575 | __v.__end_++; | 
| Howard Hinnant | b0bfd9b | 2012-02-15 00:41:34 | [diff] [blame] | 1576 | __swap_out_circular_buffer(__v); | 
|  | 1577 | } | 
|  | 1578 |  | 
|  | 1579 | template <class _Tp, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 | [diff] [blame] | 1580 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1581 | void | 
|  | 1582 | vector<_Tp, _Allocator>::push_back(const_reference __x) | 
|  | 1583 | { | 
| Howard Hinnant | b0bfd9b | 2012-02-15 00:41:34 | [diff] [blame] | 1584 | if (this->__end_ != this->__end_cap()) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1585 | { | 
| Kostya Serebryany | 497f912 | 2014-09-02 23:43:38 | [diff] [blame] | 1586 | __RAII_IncreaseAnnotator __annotator(*this); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1587 | __alloc_traits::construct(this->__alloc(), | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 1588 | _VSTD::__to_raw_pointer(this->__end_), __x); | 
| Kostya Serebryany | 497f912 | 2014-09-02 23:43:38 | [diff] [blame] | 1589 | __annotator.__done(); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1590 | ++this->__end_; | 
|  | 1591 | } | 
|  | 1592 | else | 
| Howard Hinnant | b0bfd9b | 2012-02-15 00:41:34 | [diff] [blame] | 1593 | __push_back_slow_path(__x); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1594 | } | 
|  | 1595 |  | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 | [diff] [blame] | 1596 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1597 |  | 
|  | 1598 | template <class _Tp, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 | [diff] [blame] | 1599 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1600 | void | 
|  | 1601 | vector<_Tp, _Allocator>::push_back(value_type&& __x) | 
|  | 1602 | { | 
|  | 1603 | if (this->__end_ < this->__end_cap()) | 
|  | 1604 | { | 
| Kostya Serebryany | 497f912 | 2014-09-02 23:43:38 | [diff] [blame] | 1605 | __RAII_IncreaseAnnotator __annotator(*this); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1606 | __alloc_traits::construct(this->__alloc(), | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 1607 | _VSTD::__to_raw_pointer(this->__end_), | 
|  | 1608 | _VSTD::move(__x)); | 
| Kostya Serebryany | 497f912 | 2014-09-02 23:43:38 | [diff] [blame] | 1609 | __annotator.__done(); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1610 | ++this->__end_; | 
|  | 1611 | } | 
|  | 1612 | else | 
| Howard Hinnant | b0bfd9b | 2012-02-15 00:41:34 | [diff] [blame] | 1613 | __push_back_slow_path(_VSTD::move(__x)); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1614 | } | 
|  | 1615 |  | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 | [diff] [blame] | 1616 | #ifndef _LIBCPP_HAS_NO_VARIADICS | 
|  | 1617 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1618 | template <class _Tp, class _Allocator> | 
|  | 1619 | template <class... _Args> | 
|  | 1620 | void | 
| Howard Hinnant | 0438ea2 | 2012-02-26 15:30:12 | [diff] [blame] | 1621 | vector<_Tp, _Allocator>::__emplace_back_slow_path(_Args&&... __args) | 
|  | 1622 | { | 
|  | 1623 | allocator_type& __a = this->__alloc(); | 
|  | 1624 | __split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), size(), __a); | 
|  | 1625 | // __v.emplace_back(_VSTD::forward<_Args>(__args)...); | 
| Howard Hinnant | f619e23 | 2013-01-11 20:36:59 | [diff] [blame] | 1626 | __alloc_traits::construct(__a, _VSTD::__to_raw_pointer(__v.__end_), _VSTD::forward<_Args>(__args)...); | 
|  | 1627 | __v.__end_++; | 
| Howard Hinnant | 0438ea2 | 2012-02-26 15:30:12 | [diff] [blame] | 1628 | __swap_out_circular_buffer(__v); | 
|  | 1629 | } | 
|  | 1630 |  | 
|  | 1631 | template <class _Tp, class _Allocator> | 
|  | 1632 | template <class... _Args> | 
| Evgeniy Stepanov | a3b25f8 | 2015-11-07 01:22:13 | [diff] [blame] | 1633 | inline | 
| Marshall Clow | 4e42dc9 | 2017-01-24 23:09:12 | [diff] [blame] | 1634 | #if _LIBCPP_STD_VER > 14 | 
| Eric Fiselier | 3816ef9 | 2016-07-21 03:20:17 | [diff] [blame] | 1635 | typename vector<_Tp, _Allocator>::reference | 
| Marshall Clow | 4e42dc9 | 2017-01-24 23:09:12 | [diff] [blame] | 1636 | #else | 
|  | 1637 | void | 
|  | 1638 | #endif | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1639 | vector<_Tp, _Allocator>::emplace_back(_Args&&... __args) | 
|  | 1640 | { | 
|  | 1641 | if (this->__end_ < this->__end_cap()) | 
|  | 1642 | { | 
| Kostya Serebryany | 497f912 | 2014-09-02 23:43:38 | [diff] [blame] | 1643 | __RAII_IncreaseAnnotator __annotator(*this); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1644 | __alloc_traits::construct(this->__alloc(), | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 1645 | _VSTD::__to_raw_pointer(this->__end_), | 
|  | 1646 | _VSTD::forward<_Args>(__args)...); | 
| Kostya Serebryany | 497f912 | 2014-09-02 23:43:38 | [diff] [blame] | 1647 | __annotator.__done(); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1648 | ++this->__end_; | 
|  | 1649 | } | 
|  | 1650 | else | 
| Howard Hinnant | 0438ea2 | 2012-02-26 15:30:12 | [diff] [blame] | 1651 | __emplace_back_slow_path(_VSTD::forward<_Args>(__args)...); | 
| Marshall Clow | 4e42dc9 | 2017-01-24 23:09:12 | [diff] [blame] | 1652 | #if _LIBCPP_STD_VER > 14 | 
| Eric Fiselier | 3816ef9 | 2016-07-21 03:20:17 | [diff] [blame] | 1653 | return this->back(); | 
| Marshall Clow | 4e42dc9 | 2017-01-24 23:09:12 | [diff] [blame] | 1654 | #endif | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1655 | } | 
|  | 1656 |  | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 | [diff] [blame] | 1657 | #endif // _LIBCPP_HAS_NO_VARIADICS | 
|  | 1658 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1659 |  | 
|  | 1660 | template <class _Tp, class _Allocator> | 
| Evgeniy Stepanov | a3b25f8 | 2015-11-07 01:22:13 | [diff] [blame] | 1661 | inline | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1662 | void | 
|  | 1663 | vector<_Tp, _Allocator>::pop_back() | 
|  | 1664 | { | 
| Howard Hinnant | 7a563db | 2011-09-14 18:33:51 | [diff] [blame] | 1665 | _LIBCPP_ASSERT(!empty(), "vector::pop_back called for empty vector"); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1666 | this->__destruct_at_end(this->__end_ - 1); | 
|  | 1667 | } | 
|  | 1668 |  | 
|  | 1669 | template <class _Tp, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 | [diff] [blame] | 1670 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1671 | typename vector<_Tp, _Allocator>::iterator | 
|  | 1672 | vector<_Tp, _Allocator>::erase(const_iterator __position) | 
|  | 1673 | { | 
| Howard Hinnant | abe2628 | 2011-09-16 17:29:17 | [diff] [blame] | 1674 | #if _LIBCPP_DEBUG_LEVEL >= 2 | 
| Howard Hinnant | 7a563db | 2011-09-14 18:33:51 | [diff] [blame] | 1675 | _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this, | 
|  | 1676 | "vector::erase(iterator) called with an iterator not" | 
|  | 1677 | " referring to this vector"); | 
| Howard Hinnant | abe2628 | 2011-09-16 17:29:17 | [diff] [blame] | 1678 | #endif | 
| Howard Hinnant | 782da33 | 2013-03-25 22:12:26 | [diff] [blame] | 1679 | _LIBCPP_ASSERT(__position != end(), | 
|  | 1680 | "vector::erase(iterator) called with a non-dereferenceable iterator"); | 
| Howard Hinnant | 2c39cbe | 2013-06-27 19:35:32 | [diff] [blame] | 1681 | difference_type __ps = __position - cbegin(); | 
|  | 1682 | pointer __p = this->__begin_ + __ps; | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 1683 | this->__destruct_at_end(_VSTD::move(__p + 1, this->__end_, __p)); | 
| Eric Fiselier | fb34238 | 2016-12-28 06:06:09 | [diff] [blame] | 1684 | this->__invalidate_iterators_past(__p-1); | 
|  | 1685 | iterator __r = __make_iter(__p); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1686 | return __r; | 
|  | 1687 | } | 
|  | 1688 |  | 
|  | 1689 | template <class _Tp, class _Allocator> | 
|  | 1690 | typename vector<_Tp, _Allocator>::iterator | 
|  | 1691 | vector<_Tp, _Allocator>::erase(const_iterator __first, const_iterator __last) | 
|  | 1692 | { | 
| Howard Hinnant | abe2628 | 2011-09-16 17:29:17 | [diff] [blame] | 1693 | #if _LIBCPP_DEBUG_LEVEL >= 2 | 
| Howard Hinnant | 7a563db | 2011-09-14 18:33:51 | [diff] [blame] | 1694 | _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__first) == this, | 
|  | 1695 | "vector::erase(iterator, iterator) called with an iterator not" | 
|  | 1696 | " referring to this vector"); | 
| Eric Fiselier | fb34238 | 2016-12-28 06:06:09 | [diff] [blame] | 1697 | _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__last) == this, | 
|  | 1698 | "vector::erase(iterator, iterator) called with an iterator not" | 
|  | 1699 | " referring to this vector"); | 
| Howard Hinnant | abe2628 | 2011-09-16 17:29:17 | [diff] [blame] | 1700 | #endif | 
| Howard Hinnant | 7a563db | 2011-09-14 18:33:51 | [diff] [blame] | 1701 | _LIBCPP_ASSERT(__first <= __last, "vector::erase(first, last) called with invalid range"); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1702 | pointer __p = this->__begin_ + (__first - begin()); | 
| Eric Fiselier | fb34238 | 2016-12-28 06:06:09 | [diff] [blame] | 1703 | if (__first != __last) { | 
| Howard Hinnant | b4e67cf | 2013-04-18 15:02:57 | [diff] [blame] | 1704 | this->__destruct_at_end(_VSTD::move(__p + (__last - __first), this->__end_, __p)); | 
| Eric Fiselier | fb34238 | 2016-12-28 06:06:09 | [diff] [blame] | 1705 | this->__invalidate_iterators_past(__p - 1); | 
|  | 1706 | } | 
|  | 1707 | iterator __r = __make_iter(__p); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1708 | return __r; | 
|  | 1709 | } | 
|  | 1710 |  | 
|  | 1711 | template <class _Tp, class _Allocator> | 
|  | 1712 | void | 
|  | 1713 | vector<_Tp, _Allocator>::__move_range(pointer __from_s, pointer __from_e, pointer __to) | 
|  | 1714 | { | 
|  | 1715 | pointer __old_last = this->__end_; | 
|  | 1716 | difference_type __n = __old_last - __to; | 
|  | 1717 | for (pointer __i = __from_s + __n; __i < __from_e; ++__i, ++this->__end_) | 
|  | 1718 | __alloc_traits::construct(this->__alloc(), | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 1719 | _VSTD::__to_raw_pointer(this->__end_), | 
|  | 1720 | _VSTD::move(*__i)); | 
|  | 1721 | _VSTD::move_backward(__from_s, __from_s + __n, __old_last); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1722 | } | 
|  | 1723 |  | 
|  | 1724 | template <class _Tp, class _Allocator> | 
|  | 1725 | typename vector<_Tp, _Allocator>::iterator | 
|  | 1726 | vector<_Tp, _Allocator>::insert(const_iterator __position, const_reference __x) | 
|  | 1727 | { | 
| Howard Hinnant | abe2628 | 2011-09-16 17:29:17 | [diff] [blame] | 1728 | #if _LIBCPP_DEBUG_LEVEL >= 2 | 
| Howard Hinnant | 7a563db | 2011-09-14 18:33:51 | [diff] [blame] | 1729 | _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this, | 
|  | 1730 | "vector::insert(iterator, x) called with an iterator not" | 
|  | 1731 | " referring to this vector"); | 
| Howard Hinnant | abe2628 | 2011-09-16 17:29:17 | [diff] [blame] | 1732 | #endif | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1733 | pointer __p = this->__begin_ + (__position - begin()); | 
|  | 1734 | if (this->__end_ < this->__end_cap()) | 
|  | 1735 | { | 
| Kostya Serebryany | 497f912 | 2014-09-02 23:43:38 | [diff] [blame] | 1736 | __RAII_IncreaseAnnotator __annotator(*this); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1737 | if (__p == this->__end_) | 
|  | 1738 | { | 
|  | 1739 | __alloc_traits::construct(this->__alloc(), | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 1740 | _VSTD::__to_raw_pointer(this->__end_), __x); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1741 | ++this->__end_; | 
|  | 1742 | } | 
|  | 1743 | else | 
|  | 1744 | { | 
|  | 1745 | __move_range(__p, this->__end_, __p + 1); | 
|  | 1746 | const_pointer __xr = pointer_traits<const_pointer>::pointer_to(__x); | 
|  | 1747 | if (__p <= __xr && __xr < this->__end_) | 
|  | 1748 | ++__xr; | 
|  | 1749 | *__p = *__xr; | 
|  | 1750 | } | 
| Kostya Serebryany | 497f912 | 2014-09-02 23:43:38 | [diff] [blame] | 1751 | __annotator.__done(); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1752 | } | 
|  | 1753 | else | 
|  | 1754 | { | 
|  | 1755 | allocator_type& __a = this->__alloc(); | 
|  | 1756 | __split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), __p - this->__begin_, __a); | 
|  | 1757 | __v.push_back(__x); | 
|  | 1758 | __p = __swap_out_circular_buffer(__v, __p); | 
|  | 1759 | } | 
|  | 1760 | return __make_iter(__p); | 
|  | 1761 | } | 
|  | 1762 |  | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 | [diff] [blame] | 1763 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1764 |  | 
|  | 1765 | template <class _Tp, class _Allocator> | 
|  | 1766 | typename vector<_Tp, _Allocator>::iterator | 
|  | 1767 | vector<_Tp, _Allocator>::insert(const_iterator __position, value_type&& __x) | 
|  | 1768 | { | 
| Howard Hinnant | abe2628 | 2011-09-16 17:29:17 | [diff] [blame] | 1769 | #if _LIBCPP_DEBUG_LEVEL >= 2 | 
| Howard Hinnant | 7a563db | 2011-09-14 18:33:51 | [diff] [blame] | 1770 | _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this, | 
|  | 1771 | "vector::insert(iterator, x) called with an iterator not" | 
|  | 1772 | " referring to this vector"); | 
| Howard Hinnant | abe2628 | 2011-09-16 17:29:17 | [diff] [blame] | 1773 | #endif | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1774 | pointer __p = this->__begin_ + (__position - begin()); | 
|  | 1775 | if (this->__end_ < this->__end_cap()) | 
|  | 1776 | { | 
| Kostya Serebryany | 497f912 | 2014-09-02 23:43:38 | [diff] [blame] | 1777 | __RAII_IncreaseAnnotator __annotator(*this); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1778 | if (__p == this->__end_) | 
|  | 1779 | { | 
|  | 1780 | __alloc_traits::construct(this->__alloc(), | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 1781 | _VSTD::__to_raw_pointer(this->__end_), | 
|  | 1782 | _VSTD::move(__x)); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1783 | ++this->__end_; | 
|  | 1784 | } | 
|  | 1785 | else | 
|  | 1786 | { | 
|  | 1787 | __move_range(__p, this->__end_, __p + 1); | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 1788 | *__p = _VSTD::move(__x); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1789 | } | 
| Kostya Serebryany | 497f912 | 2014-09-02 23:43:38 | [diff] [blame] | 1790 | __annotator.__done(); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1791 | } | 
|  | 1792 | else | 
|  | 1793 | { | 
|  | 1794 | allocator_type& __a = this->__alloc(); | 
|  | 1795 | __split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), __p - this->__begin_, __a); | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 1796 | __v.push_back(_VSTD::move(__x)); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1797 | __p = __swap_out_circular_buffer(__v, __p); | 
|  | 1798 | } | 
|  | 1799 | return __make_iter(__p); | 
|  | 1800 | } | 
|  | 1801 |  | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 | [diff] [blame] | 1802 | #ifndef _LIBCPP_HAS_NO_VARIADICS | 
|  | 1803 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1804 | template <class _Tp, class _Allocator> | 
|  | 1805 | template <class... _Args> | 
|  | 1806 | typename vector<_Tp, _Allocator>::iterator | 
|  | 1807 | vector<_Tp, _Allocator>::emplace(const_iterator __position, _Args&&... __args) | 
|  | 1808 | { | 
| Howard Hinnant | abe2628 | 2011-09-16 17:29:17 | [diff] [blame] | 1809 | #if _LIBCPP_DEBUG_LEVEL >= 2 | 
| Howard Hinnant | 7a563db | 2011-09-14 18:33:51 | [diff] [blame] | 1810 | _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this, | 
|  | 1811 | "vector::emplace(iterator, x) called with an iterator not" | 
|  | 1812 | " referring to this vector"); | 
| Howard Hinnant | abe2628 | 2011-09-16 17:29:17 | [diff] [blame] | 1813 | #endif | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1814 | pointer __p = this->__begin_ + (__position - begin()); | 
|  | 1815 | if (this->__end_ < this->__end_cap()) | 
|  | 1816 | { | 
| Kostya Serebryany | 497f912 | 2014-09-02 23:43:38 | [diff] [blame] | 1817 | __RAII_IncreaseAnnotator __annotator(*this); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1818 | if (__p == this->__end_) | 
|  | 1819 | { | 
|  | 1820 | __alloc_traits::construct(this->__alloc(), | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 1821 | _VSTD::__to_raw_pointer(this->__end_), | 
|  | 1822 | _VSTD::forward<_Args>(__args)...); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1823 | ++this->__end_; | 
|  | 1824 | } | 
|  | 1825 | else | 
|  | 1826 | { | 
| Marshall Clow | 51d7e8e | 2016-07-11 21:38:08 | [diff] [blame] | 1827 | __temp_value<value_type, _Allocator> __tmp(this->__alloc(), _VSTD::forward<_Args>(__args)...); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1828 | __move_range(__p, this->__end_, __p + 1); | 
| Marshall Clow | 51d7e8e | 2016-07-11 21:38:08 | [diff] [blame] | 1829 | *__p = _VSTD::move(__tmp.get()); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1830 | } | 
| Kostya Serebryany | 497f912 | 2014-09-02 23:43:38 | [diff] [blame] | 1831 | __annotator.__done(); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1832 | } | 
|  | 1833 | else | 
|  | 1834 | { | 
|  | 1835 | allocator_type& __a = this->__alloc(); | 
|  | 1836 | __split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), __p - this->__begin_, __a); | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 1837 | __v.emplace_back(_VSTD::forward<_Args>(__args)...); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1838 | __p = __swap_out_circular_buffer(__v, __p); | 
|  | 1839 | } | 
|  | 1840 | return __make_iter(__p); | 
|  | 1841 | } | 
|  | 1842 |  | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 | [diff] [blame] | 1843 | #endif // _LIBCPP_HAS_NO_VARIADICS | 
|  | 1844 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1845 |  | 
|  | 1846 | template <class _Tp, class _Allocator> | 
|  | 1847 | typename vector<_Tp, _Allocator>::iterator | 
|  | 1848 | vector<_Tp, _Allocator>::insert(const_iterator __position, size_type __n, const_reference __x) | 
|  | 1849 | { | 
| Howard Hinnant | abe2628 | 2011-09-16 17:29:17 | [diff] [blame] | 1850 | #if _LIBCPP_DEBUG_LEVEL >= 2 | 
| Howard Hinnant | 7a563db | 2011-09-14 18:33:51 | [diff] [blame] | 1851 | _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this, | 
|  | 1852 | "vector::insert(iterator, n, x) called with an iterator not" | 
|  | 1853 | " referring to this vector"); | 
| Howard Hinnant | abe2628 | 2011-09-16 17:29:17 | [diff] [blame] | 1854 | #endif | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1855 | pointer __p = this->__begin_ + (__position - begin()); | 
|  | 1856 | if (__n > 0) | 
|  | 1857 | { | 
|  | 1858 | if (__n <= static_cast<size_type>(this->__end_cap() - this->__end_)) | 
|  | 1859 | { | 
|  | 1860 | size_type __old_n = __n; | 
|  | 1861 | pointer __old_last = this->__end_; | 
|  | 1862 | if (__n > static_cast<size_type>(this->__end_ - __p)) | 
|  | 1863 | { | 
|  | 1864 | size_type __cx = __n - (this->__end_ - __p); | 
|  | 1865 | __construct_at_end(__cx, __x); | 
|  | 1866 | __n -= __cx; | 
|  | 1867 | } | 
|  | 1868 | if (__n > 0) | 
|  | 1869 | { | 
| Eric Fiselier | d759095 | 2014-11-14 18:28:36 | [diff] [blame] | 1870 | __RAII_IncreaseAnnotator __annotator(*this, __n); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1871 | __move_range(__p, __old_last, __p + __old_n); | 
| Kostya Serebryany | 497f912 | 2014-09-02 23:43:38 | [diff] [blame] | 1872 | __annotator.__done(); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1873 | const_pointer __xr = pointer_traits<const_pointer>::pointer_to(__x); | 
|  | 1874 | if (__p <= __xr && __xr < this->__end_) | 
|  | 1875 | __xr += __old_n; | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 1876 | _VSTD::fill_n(__p, __n, *__xr); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1877 | } | 
|  | 1878 | } | 
|  | 1879 | else | 
|  | 1880 | { | 
|  | 1881 | allocator_type& __a = this->__alloc(); | 
|  | 1882 | __split_buffer<value_type, allocator_type&> __v(__recommend(size() + __n), __p - this->__begin_, __a); | 
|  | 1883 | __v.__construct_at_end(__n, __x); | 
|  | 1884 | __p = __swap_out_circular_buffer(__v, __p); | 
|  | 1885 | } | 
|  | 1886 | } | 
|  | 1887 | return __make_iter(__p); | 
|  | 1888 | } | 
|  | 1889 |  | 
|  | 1890 | template <class _Tp, class _Allocator> | 
|  | 1891 | template <class _InputIterator> | 
|  | 1892 | typename enable_if | 
|  | 1893 | < | 
|  | 1894 | __is_input_iterator <_InputIterator>::value && | 
| Howard Hinnant | 742fecb | 2013-03-28 17:44:32 | [diff] [blame] | 1895 | !__is_forward_iterator<_InputIterator>::value && | 
|  | 1896 | is_constructible< | 
|  | 1897 | _Tp, | 
|  | 1898 | typename iterator_traits<_InputIterator>::reference>::value, | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1899 | typename vector<_Tp, _Allocator>::iterator | 
|  | 1900 | >::type | 
|  | 1901 | vector<_Tp, _Allocator>::insert(const_iterator __position, _InputIterator __first, _InputIterator __last) | 
|  | 1902 | { | 
| Howard Hinnant | abe2628 | 2011-09-16 17:29:17 | [diff] [blame] | 1903 | #if _LIBCPP_DEBUG_LEVEL >= 2 | 
| Howard Hinnant | 7a563db | 2011-09-14 18:33:51 | [diff] [blame] | 1904 | _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this, | 
|  | 1905 | "vector::insert(iterator, range) called with an iterator not" | 
|  | 1906 | " referring to this vector"); | 
| Howard Hinnant | abe2628 | 2011-09-16 17:29:17 | [diff] [blame] | 1907 | #endif | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1908 | difference_type __off = __position - begin(); | 
|  | 1909 | pointer __p = this->__begin_ + __off; | 
|  | 1910 | allocator_type& __a = this->__alloc(); | 
|  | 1911 | pointer __old_last = this->__end_; | 
|  | 1912 | for (; this->__end_ != this->__end_cap() && __first != __last; ++__first) | 
|  | 1913 | { | 
| Eric Fiselier | 7d439a4 | 2015-07-18 18:22:12 | [diff] [blame] | 1914 | __RAII_IncreaseAnnotator __annotator(*this); | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 1915 | __alloc_traits::construct(__a, _VSTD::__to_raw_pointer(this->__end_), | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1916 | *__first); | 
|  | 1917 | ++this->__end_; | 
| Eric Fiselier | 7d439a4 | 2015-07-18 18:22:12 | [diff] [blame] | 1918 | __annotator.__done(); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1919 | } | 
|  | 1920 | __split_buffer<value_type, allocator_type&> __v(__a); | 
|  | 1921 | if (__first != __last) | 
|  | 1922 | { | 
|  | 1923 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
|  | 1924 | try | 
|  | 1925 | { | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 1926 | #endif // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1927 | __v.__construct_at_end(__first, __last); | 
|  | 1928 | difference_type __old_size = __old_last - this->__begin_; | 
|  | 1929 | difference_type __old_p = __p - this->__begin_; | 
|  | 1930 | reserve(__recommend(size() + __v.size())); | 
|  | 1931 | __p = this->__begin_ + __old_p; | 
|  | 1932 | __old_last = this->__begin_ + __old_size; | 
|  | 1933 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
|  | 1934 | } | 
|  | 1935 | catch (...) | 
|  | 1936 | { | 
|  | 1937 | erase(__make_iter(__old_last), end()); | 
|  | 1938 | throw; | 
|  | 1939 | } | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 1940 | #endif // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1941 | } | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 1942 | __p = _VSTD::rotate(__p, __old_last, this->__end_); | 
| Howard Hinnant | 0442b12 | 2011-09-16 18:41:29 | [diff] [blame] | 1943 | insert(__make_iter(__p), make_move_iterator(__v.begin()), | 
|  | 1944 | make_move_iterator(__v.end())); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1945 | return begin() + __off; | 
|  | 1946 | } | 
|  | 1947 |  | 
|  | 1948 | template <class _Tp, class _Allocator> | 
|  | 1949 | template <class _ForwardIterator> | 
|  | 1950 | typename enable_if | 
|  | 1951 | < | 
| Howard Hinnant | 742fecb | 2013-03-28 17:44:32 | [diff] [blame] | 1952 | __is_forward_iterator<_ForwardIterator>::value && | 
|  | 1953 | is_constructible< | 
|  | 1954 | _Tp, | 
|  | 1955 | typename iterator_traits<_ForwardIterator>::reference>::value, | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1956 | typename vector<_Tp, _Allocator>::iterator | 
|  | 1957 | >::type | 
|  | 1958 | vector<_Tp, _Allocator>::insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last) | 
|  | 1959 | { | 
| Howard Hinnant | abe2628 | 2011-09-16 17:29:17 | [diff] [blame] | 1960 | #if _LIBCPP_DEBUG_LEVEL >= 2 | 
| Howard Hinnant | 7a563db | 2011-09-14 18:33:51 | [diff] [blame] | 1961 | _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this, | 
|  | 1962 | "vector::insert(iterator, range) called with an iterator not" | 
|  | 1963 | " referring to this vector"); | 
| Howard Hinnant | abe2628 | 2011-09-16 17:29:17 | [diff] [blame] | 1964 | #endif | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1965 | pointer __p = this->__begin_ + (__position - begin()); | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 1966 | difference_type __n = _VSTD::distance(__first, __last); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1967 | if (__n > 0) | 
|  | 1968 | { | 
|  | 1969 | if (__n <= this->__end_cap() - this->__end_) | 
|  | 1970 | { | 
|  | 1971 | size_type __old_n = __n; | 
|  | 1972 | pointer __old_last = this->__end_; | 
|  | 1973 | _ForwardIterator __m = __last; | 
|  | 1974 | difference_type __dx = this->__end_ - __p; | 
|  | 1975 | if (__n > __dx) | 
|  | 1976 | { | 
|  | 1977 | __m = __first; | 
| Eric Fiselier | 088ed9f | 2015-03-31 16:54:19 | [diff] [blame] | 1978 | difference_type __diff = this->__end_ - __p; | 
|  | 1979 | _VSTD::advance(__m, __diff); | 
|  | 1980 | __construct_at_end(__m, __last, __n - __diff); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1981 | __n = __dx; | 
|  | 1982 | } | 
|  | 1983 | if (__n > 0) | 
|  | 1984 | { | 
| Kostya Serebryany | 497f912 | 2014-09-02 23:43:38 | [diff] [blame] | 1985 | __RAII_IncreaseAnnotator __annotator(*this, __n); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1986 | __move_range(__p, __old_last, __p + __old_n); | 
| Kostya Serebryany | 497f912 | 2014-09-02 23:43:38 | [diff] [blame] | 1987 | __annotator.__done(); | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 1988 | _VSTD::copy(__first, __m, __p); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1989 | } | 
|  | 1990 | } | 
|  | 1991 | else | 
|  | 1992 | { | 
|  | 1993 | allocator_type& __a = this->__alloc(); | 
|  | 1994 | __split_buffer<value_type, allocator_type&> __v(__recommend(size() + __n), __p - this->__begin_, __a); | 
|  | 1995 | __v.__construct_at_end(__first, __last); | 
|  | 1996 | __p = __swap_out_circular_buffer(__v, __p); | 
|  | 1997 | } | 
|  | 1998 | } | 
|  | 1999 | return __make_iter(__p); | 
|  | 2000 | } | 
|  | 2001 |  | 
|  | 2002 | template <class _Tp, class _Allocator> | 
|  | 2003 | void | 
|  | 2004 | vector<_Tp, _Allocator>::resize(size_type __sz) | 
|  | 2005 | { | 
|  | 2006 | size_type __cs = size(); | 
|  | 2007 | if (__cs < __sz) | 
|  | 2008 | this->__append(__sz - __cs); | 
|  | 2009 | else if (__cs > __sz) | 
|  | 2010 | this->__destruct_at_end(this->__begin_ + __sz); | 
|  | 2011 | } | 
|  | 2012 |  | 
|  | 2013 | template <class _Tp, class _Allocator> | 
|  | 2014 | void | 
|  | 2015 | vector<_Tp, _Allocator>::resize(size_type __sz, const_reference __x) | 
|  | 2016 | { | 
|  | 2017 | size_type __cs = size(); | 
|  | 2018 | if (__cs < __sz) | 
|  | 2019 | this->__append(__sz - __cs, __x); | 
|  | 2020 | else if (__cs > __sz) | 
|  | 2021 | this->__destruct_at_end(this->__begin_ + __sz); | 
|  | 2022 | } | 
|  | 2023 |  | 
|  | 2024 | template <class _Tp, class _Allocator> | 
|  | 2025 | void | 
|  | 2026 | vector<_Tp, _Allocator>::swap(vector& __x) | 
| Marshall Clow | 7d914d1 | 2015-07-13 20:04:56 | [diff] [blame] | 2027 | #if _LIBCPP_STD_VER >= 14 | 
| Eric Fiselier | fb34238 | 2016-12-28 06:06:09 | [diff] [blame] | 2028 | _NOEXCEPT_DEBUG | 
| Marshall Clow | 7d914d1 | 2015-07-13 20:04:56 | [diff] [blame] | 2029 | #else | 
| Eric Fiselier | fb34238 | 2016-12-28 06:06:09 | [diff] [blame] | 2030 | _NOEXCEPT_DEBUG_(!__alloc_traits::propagate_on_container_swap::value || | 
| Marshall Clow | 7d914d1 | 2015-07-13 20:04:56 | [diff] [blame] | 2031 | __is_nothrow_swappable<allocator_type>::value) | 
|  | 2032 | #endif | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2033 | { | 
| Howard Hinnant | 7a563db | 2011-09-14 18:33:51 | [diff] [blame] | 2034 | _LIBCPP_ASSERT(__alloc_traits::propagate_on_container_swap::value || | 
|  | 2035 | this->__alloc() == __x.__alloc(), | 
|  | 2036 | "vector::swap: Either propagate_on_container_swap must be true" | 
|  | 2037 | " or the allocators must compare equal"); | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 2038 | _VSTD::swap(this->__begin_, __x.__begin_); | 
|  | 2039 | _VSTD::swap(this->__end_, __x.__end_); | 
|  | 2040 | _VSTD::swap(this->__end_cap(), __x.__end_cap()); | 
| Marshall Clow | 7d914d1 | 2015-07-13 20:04:56 | [diff] [blame] | 2041 | __swap_allocator(this->__alloc(), __x.__alloc(), | 
|  | 2042 | integral_constant<bool,__alloc_traits::propagate_on_container_swap::value>()); | 
| Howard Hinnant | abe2628 | 2011-09-16 17:29:17 | [diff] [blame] | 2043 | #if _LIBCPP_DEBUG_LEVEL >= 2 | 
| Howard Hinnant | 7a563db | 2011-09-14 18:33:51 | [diff] [blame] | 2044 | __get_db()->swap(this, &__x); | 
| Howard Hinnant | abe2628 | 2011-09-16 17:29:17 | [diff] [blame] | 2045 | #endif // _LIBCPP_DEBUG_LEVEL >= 2 | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2046 | } | 
|  | 2047 |  | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 2048 | template <class _Tp, class _Allocator> | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2049 | bool | 
|  | 2050 | vector<_Tp, _Allocator>::__invariants() const | 
|  | 2051 | { | 
| Howard Hinnant | 2c39cbe | 2013-06-27 19:35:32 | [diff] [blame] | 2052 | if (this->__begin_ == nullptr) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2053 | { | 
| Howard Hinnant | 2c39cbe | 2013-06-27 19:35:32 | [diff] [blame] | 2054 | if (this->__end_ != nullptr || this->__end_cap() != nullptr) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2055 | return false; | 
|  | 2056 | } | 
|  | 2057 | else | 
|  | 2058 | { | 
|  | 2059 | if (this->__begin_ > this->__end_) | 
|  | 2060 | return false; | 
|  | 2061 | if (this->__begin_ == this->__end_cap()) | 
|  | 2062 | return false; | 
|  | 2063 | if (this->__end_ > this->__end_cap()) | 
|  | 2064 | return false; | 
|  | 2065 | } | 
|  | 2066 | return true; | 
|  | 2067 | } | 
|  | 2068 |  | 
| Howard Hinnant | abe2628 | 2011-09-16 17:29:17 | [diff] [blame] | 2069 | #if _LIBCPP_DEBUG_LEVEL >= 2 | 
| Howard Hinnant | 7a563db | 2011-09-14 18:33:51 | [diff] [blame] | 2070 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2071 | template <class _Tp, class _Allocator> | 
| Howard Hinnant | 7a563db | 2011-09-14 18:33:51 | [diff] [blame] | 2072 | bool | 
|  | 2073 | vector<_Tp, _Allocator>::__dereferenceable(const const_iterator* __i) const | 
|  | 2074 | { | 
|  | 2075 | return this->__begin_ <= __i->base() && __i->base() < this->__end_; | 
|  | 2076 | } | 
|  | 2077 |  | 
|  | 2078 | template <class _Tp, class _Allocator> | 
|  | 2079 | bool | 
|  | 2080 | vector<_Tp, _Allocator>::__decrementable(const const_iterator* __i) const | 
|  | 2081 | { | 
|  | 2082 | return this->__begin_ < __i->base() && __i->base() <= this->__end_; | 
|  | 2083 | } | 
|  | 2084 |  | 
|  | 2085 | template <class _Tp, class _Allocator> | 
|  | 2086 | bool | 
|  | 2087 | vector<_Tp, _Allocator>::__addable(const const_iterator* __i, ptrdiff_t __n) const | 
|  | 2088 | { | 
|  | 2089 | const_pointer __p = __i->base() + __n; | 
|  | 2090 | return this->__begin_ <= __p && __p <= this->__end_; | 
|  | 2091 | } | 
|  | 2092 |  | 
|  | 2093 | template <class _Tp, class _Allocator> | 
|  | 2094 | bool | 
|  | 2095 | vector<_Tp, _Allocator>::__subscriptable(const const_iterator* __i, ptrdiff_t __n) const | 
|  | 2096 | { | 
|  | 2097 | const_pointer __p = __i->base() + __n; | 
|  | 2098 | return this->__begin_ <= __p && __p < this->__end_; | 
|  | 2099 | } | 
|  | 2100 |  | 
| Howard Hinnant | abe2628 | 2011-09-16 17:29:17 | [diff] [blame] | 2101 | #endif // _LIBCPP_DEBUG_LEVEL >= 2 | 
| Howard Hinnant | 7a563db | 2011-09-14 18:33:51 | [diff] [blame] | 2102 |  | 
|  | 2103 | template <class _Tp, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 | [diff] [blame] | 2104 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2105 | void | 
|  | 2106 | vector<_Tp, _Allocator>::__invalidate_all_iterators() | 
|  | 2107 | { | 
| Howard Hinnant | abe2628 | 2011-09-16 17:29:17 | [diff] [blame] | 2108 | #if _LIBCPP_DEBUG_LEVEL >= 2 | 
| Howard Hinnant | 7a563db | 2011-09-14 18:33:51 | [diff] [blame] | 2109 | __get_db()->__invalidate_all(this); | 
| Howard Hinnant | abe2628 | 2011-09-16 17:29:17 | [diff] [blame] | 2110 | #endif // _LIBCPP_DEBUG_LEVEL >= 2 | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2111 | } | 
|  | 2112 |  | 
| Eric Fiselier | fb34238 | 2016-12-28 06:06:09 | [diff] [blame] | 2113 |  | 
|  | 2114 | template <class _Tp, class _Allocator> | 
|  | 2115 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 2116 | void | 
|  | 2117 | vector<_Tp, _Allocator>::__invalidate_iterators_past(pointer __new_last) { | 
|  | 2118 | #if _LIBCPP_DEBUG_LEVEL >= 2 | 
|  | 2119 | __c_node* __c = __get_db()->__find_c_and_lock(this); | 
|  | 2120 | for (__i_node** __p = __c->end_; __p != __c->beg_; ) { | 
|  | 2121 | --__p; | 
|  | 2122 | const_iterator* __i = static_cast<const_iterator*>((*__p)->__i_); | 
|  | 2123 | if (__i->base() > __new_last) { | 
|  | 2124 | (*__p)->__c_ = nullptr; | 
|  | 2125 | if (--__c->end_ != __p) | 
|  | 2126 | memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*)); | 
|  | 2127 | } | 
|  | 2128 | } | 
|  | 2129 | __get_db()->unlock(); | 
|  | 2130 | #else | 
|  | 2131 | ((void)__new_last); | 
|  | 2132 | #endif | 
|  | 2133 | } | 
|  | 2134 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2135 | // vector<bool> | 
|  | 2136 |  | 
|  | 2137 | template <class _Allocator> class vector<bool, _Allocator>; | 
|  | 2138 |  | 
|  | 2139 | template <class _Allocator> struct hash<vector<bool, _Allocator> >; | 
|  | 2140 |  | 
|  | 2141 | template <class _Allocator> | 
| Howard Hinnant | f03c3b4 | 2011-07-02 20:33:23 | [diff] [blame] | 2142 | struct __has_storage_type<vector<bool, _Allocator> > | 
|  | 2143 | { | 
|  | 2144 | static const bool value = true; | 
|  | 2145 | }; | 
|  | 2146 |  | 
|  | 2147 | template <class _Allocator> | 
| Eric Fiselier | c3589a8 | 2017-01-04 23:56:00 | [diff] [blame] | 2148 | class _LIBCPP_TEMPLATE_VIS vector<bool, _Allocator> | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2149 | : private __vector_base_common<true> | 
|  | 2150 | { | 
|  | 2151 | public: | 
|  | 2152 | typedef vector __self; | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 2153 | typedef bool value_type; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2154 | typedef _Allocator allocator_type; | 
|  | 2155 | typedef allocator_traits<allocator_type> __alloc_traits; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2156 | typedef typename __alloc_traits::size_type size_type; | 
|  | 2157 | typedef typename __alloc_traits::difference_type difference_type; | 
| Howard Hinnant | f867f63 | 2012-05-07 16:50:38 | [diff] [blame] | 2158 | typedef size_type __storage_type; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2159 | typedef __bit_iterator<vector, false> pointer; | 
|  | 2160 | typedef __bit_iterator<vector, true> const_pointer; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2161 | typedef pointer iterator; | 
|  | 2162 | typedef const_pointer const_iterator; | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 2163 | typedef _VSTD::reverse_iterator<iterator> reverse_iterator; | 
|  | 2164 | typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2165 |  | 
|  | 2166 | private: | 
| Marshall Clow | 66302c6 | 2015-04-07 05:21:38 | [diff] [blame] | 2167 | typedef typename __rebind_alloc_helper<__alloc_traits, __storage_type>::type __storage_allocator; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2168 | typedef allocator_traits<__storage_allocator> __storage_traits; | 
|  | 2169 | typedef typename __storage_traits::pointer __storage_pointer; | 
|  | 2170 | typedef typename __storage_traits::const_pointer __const_storage_pointer; | 
|  | 2171 |  | 
|  | 2172 | __storage_pointer __begin_; | 
|  | 2173 | size_type __size_; | 
|  | 2174 | __compressed_pair<size_type, __storage_allocator> __cap_alloc_; | 
| Howard Hinnant | 2bf1c08 | 2011-07-09 15:50:42 | [diff] [blame] | 2175 | public: | 
| Howard Hinnant | f03c3b4 | 2011-07-02 20:33:23 | [diff] [blame] | 2176 | typedef __bit_reference<vector> reference; | 
|  | 2177 | typedef __bit_const_reference<vector> const_reference; | 
| Howard Hinnant | 2bf1c08 | 2011-07-09 15:50:42 | [diff] [blame] | 2178 | private: | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 2179 | _LIBCPP_INLINE_VISIBILITY | 
|  | 2180 | size_type& __cap() _NOEXCEPT | 
|  | 2181 | {return __cap_alloc_.first();} | 
|  | 2182 | _LIBCPP_INLINE_VISIBILITY | 
|  | 2183 | const size_type& __cap() const _NOEXCEPT | 
|  | 2184 | {return __cap_alloc_.first();} | 
|  | 2185 | _LIBCPP_INLINE_VISIBILITY | 
|  | 2186 | __storage_allocator& __alloc() _NOEXCEPT | 
|  | 2187 | {return __cap_alloc_.second();} | 
|  | 2188 | _LIBCPP_INLINE_VISIBILITY | 
|  | 2189 | const __storage_allocator& __alloc() const _NOEXCEPT | 
|  | 2190 | {return __cap_alloc_.second();} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2191 |  | 
|  | 2192 | static const unsigned __bits_per_word = static_cast<unsigned>(sizeof(__storage_type) * CHAR_BIT); | 
|  | 2193 |  | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 2194 | _LIBCPP_INLINE_VISIBILITY | 
|  | 2195 | static size_type __internal_cap_to_external(size_type __n) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2196 | {return __n * __bits_per_word;} | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 2197 | _LIBCPP_INLINE_VISIBILITY | 
|  | 2198 | static size_type __external_cap_to_internal(size_type __n) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2199 | {return (__n - 1) / __bits_per_word + 1;} | 
|  | 2200 |  | 
|  | 2201 | public: | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 2202 | _LIBCPP_INLINE_VISIBILITY | 
| Marshall Clow | c912c0c | 2015-06-04 02:05:41 | [diff] [blame] | 2203 | vector() _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value); | 
| Marshall Clow | 127db91 | 2015-06-04 00:10:20 | [diff] [blame] | 2204 |  | 
|  | 2205 | _LIBCPP_INLINE_VISIBILITY explicit vector(const allocator_type& __a) | 
|  | 2206 | #if _LIBCPP_STD_VER <= 14 | 
|  | 2207 | _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value); | 
|  | 2208 | #else | 
|  | 2209 | _NOEXCEPT; | 
|  | 2210 | #endif | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2211 | ~vector(); | 
|  | 2212 | explicit vector(size_type __n); | 
| Marshall Clow | a49a2c9 | 2013-09-14 00:47:59 | [diff] [blame] | 2213 | #if _LIBCPP_STD_VER > 11 | 
|  | 2214 | explicit vector(size_type __n, const allocator_type& __a); | 
|  | 2215 | #endif | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2216 | vector(size_type __n, const value_type& __v); | 
|  | 2217 | vector(size_type __n, const value_type& __v, const allocator_type& __a); | 
|  | 2218 | template <class _InputIterator> | 
|  | 2219 | vector(_InputIterator __first, _InputIterator __last, | 
|  | 2220 | typename enable_if<__is_input_iterator <_InputIterator>::value && | 
|  | 2221 | !__is_forward_iterator<_InputIterator>::value>::type* = 0); | 
|  | 2222 | template <class _InputIterator> | 
|  | 2223 | vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a, | 
|  | 2224 | typename enable_if<__is_input_iterator <_InputIterator>::value && | 
|  | 2225 | !__is_forward_iterator<_InputIterator>::value>::type* = 0); | 
|  | 2226 | template <class _ForwardIterator> | 
|  | 2227 | vector(_ForwardIterator __first, _ForwardIterator __last, | 
|  | 2228 | typename enable_if<__is_forward_iterator<_ForwardIterator>::value>::type* = 0); | 
|  | 2229 | template <class _ForwardIterator> | 
|  | 2230 | vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a, | 
|  | 2231 | typename enable_if<__is_forward_iterator<_ForwardIterator>::value>::type* = 0); | 
|  | 2232 |  | 
|  | 2233 | vector(const vector& __v); | 
|  | 2234 | vector(const vector& __v, const allocator_type& __a); | 
|  | 2235 | vector& operator=(const vector& __v); | 
| Howard Hinnant | e3e3291 | 2011-08-12 21:56:02 | [diff] [blame] | 2236 | #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2237 | vector(initializer_list<value_type> __il); | 
|  | 2238 | vector(initializer_list<value_type> __il, const allocator_type& __a); | 
| Howard Hinnant | e3e3291 | 2011-08-12 21:56:02 | [diff] [blame] | 2239 | #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2240 |  | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 | [diff] [blame] | 2241 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 2242 | _LIBCPP_INLINE_VISIBILITY | 
|  | 2243 | vector(vector&& __v) | 
| Marshall Clow | 119ed47 | 2015-07-14 14:46:32 | [diff] [blame] | 2244 | #if _LIBCPP_STD_VER > 14 | 
|  | 2245 | _NOEXCEPT; | 
|  | 2246 | #else | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 2247 | _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value); | 
| Marshall Clow | 119ed47 | 2015-07-14 14:46:32 | [diff] [blame] | 2248 | #endif | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2249 | vector(vector&& __v, const allocator_type& __a); | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 2250 | _LIBCPP_INLINE_VISIBILITY | 
|  | 2251 | vector& operator=(vector&& __v) | 
| Marshall Clow | af961ed | 2015-08-18 18:57:00 | [diff] [blame] | 2252 | _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value)); | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 | [diff] [blame] | 2253 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | e3e3291 | 2011-08-12 21:56:02 | [diff] [blame] | 2254 | #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS | 
| Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 | [diff] [blame] | 2255 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2256 | vector& operator=(initializer_list<value_type> __il) | 
|  | 2257 | {assign(__il.begin(), __il.end()); return *this;} | 
| Howard Hinnant | e3e3291 | 2011-08-12 21:56:02 | [diff] [blame] | 2258 | #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2259 |  | 
|  | 2260 | template <class _InputIterator> | 
|  | 2261 | typename enable_if | 
|  | 2262 | < | 
|  | 2263 | __is_input_iterator<_InputIterator>::value && | 
|  | 2264 | !__is_forward_iterator<_InputIterator>::value, | 
|  | 2265 | void | 
|  | 2266 | >::type | 
|  | 2267 | assign(_InputIterator __first, _InputIterator __last); | 
|  | 2268 | template <class _ForwardIterator> | 
|  | 2269 | typename enable_if | 
|  | 2270 | < | 
|  | 2271 | __is_forward_iterator<_ForwardIterator>::value, | 
|  | 2272 | void | 
|  | 2273 | >::type | 
|  | 2274 | assign(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 2275 |  | 
|  | 2276 | void assign(size_type __n, const value_type& __x); | 
| Howard Hinnant | e3e3291 | 2011-08-12 21:56:02 | [diff] [blame] | 2277 | #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS | 
| Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 | [diff] [blame] | 2278 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2279 | void assign(initializer_list<value_type> __il) | 
|  | 2280 | {assign(__il.begin(), __il.end());} | 
| Howard Hinnant | e3e3291 | 2011-08-12 21:56:02 | [diff] [blame] | 2281 | #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2282 |  | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 2283 | _LIBCPP_INLINE_VISIBILITY allocator_type get_allocator() const _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2284 | {return allocator_type(this->__alloc());} | 
|  | 2285 |  | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 2286 | size_type max_size() const _NOEXCEPT; | 
|  | 2287 | _LIBCPP_INLINE_VISIBILITY | 
|  | 2288 | size_type capacity() const _NOEXCEPT | 
|  | 2289 | {return __internal_cap_to_external(__cap());} | 
|  | 2290 | _LIBCPP_INLINE_VISIBILITY | 
|  | 2291 | size_type size() const _NOEXCEPT | 
|  | 2292 | {return __size_;} | 
|  | 2293 | _LIBCPP_INLINE_VISIBILITY | 
|  | 2294 | bool empty() const _NOEXCEPT | 
|  | 2295 | {return __size_ == 0;} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2296 | void reserve(size_type __n); | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 2297 | void shrink_to_fit() _NOEXCEPT; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2298 |  | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 2299 | _LIBCPP_INLINE_VISIBILITY | 
|  | 2300 | iterator begin() _NOEXCEPT | 
|  | 2301 | {return __make_iter(0);} | 
|  | 2302 | _LIBCPP_INLINE_VISIBILITY | 
|  | 2303 | const_iterator begin() const _NOEXCEPT | 
|  | 2304 | {return __make_iter(0);} | 
|  | 2305 | _LIBCPP_INLINE_VISIBILITY | 
|  | 2306 | iterator end() _NOEXCEPT | 
|  | 2307 | {return __make_iter(__size_);} | 
|  | 2308 | _LIBCPP_INLINE_VISIBILITY | 
|  | 2309 | const_iterator end() const _NOEXCEPT | 
|  | 2310 | {return __make_iter(__size_);} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2311 |  | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 2312 | _LIBCPP_INLINE_VISIBILITY | 
|  | 2313 | reverse_iterator rbegin() _NOEXCEPT | 
|  | 2314 | {return reverse_iterator(end());} | 
|  | 2315 | _LIBCPP_INLINE_VISIBILITY | 
|  | 2316 | const_reverse_iterator rbegin() const _NOEXCEPT | 
|  | 2317 | {return const_reverse_iterator(end());} | 
|  | 2318 | _LIBCPP_INLINE_VISIBILITY | 
|  | 2319 | reverse_iterator rend() _NOEXCEPT | 
|  | 2320 | {return reverse_iterator(begin());} | 
|  | 2321 | _LIBCPP_INLINE_VISIBILITY | 
|  | 2322 | const_reverse_iterator rend() const _NOEXCEPT | 
|  | 2323 | {return const_reverse_iterator(begin());} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2324 |  | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 2325 | _LIBCPP_INLINE_VISIBILITY | 
|  | 2326 | const_iterator cbegin() const _NOEXCEPT | 
|  | 2327 | {return __make_iter(0);} | 
|  | 2328 | _LIBCPP_INLINE_VISIBILITY | 
|  | 2329 | const_iterator cend() const _NOEXCEPT | 
|  | 2330 | {return __make_iter(__size_);} | 
|  | 2331 | _LIBCPP_INLINE_VISIBILITY | 
|  | 2332 | const_reverse_iterator crbegin() const _NOEXCEPT | 
|  | 2333 | {return rbegin();} | 
|  | 2334 | _LIBCPP_INLINE_VISIBILITY | 
|  | 2335 | const_reverse_iterator crend() const _NOEXCEPT | 
|  | 2336 | {return rend();} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2337 |  | 
|  | 2338 | _LIBCPP_INLINE_VISIBILITY reference operator[](size_type __n) {return __make_ref(__n);} | 
|  | 2339 | _LIBCPP_INLINE_VISIBILITY const_reference operator[](size_type __n) const {return __make_ref(__n);} | 
|  | 2340 | reference at(size_type __n); | 
|  | 2341 | const_reference at(size_type __n) const; | 
|  | 2342 |  | 
|  | 2343 | _LIBCPP_INLINE_VISIBILITY reference front() {return __make_ref(0);} | 
|  | 2344 | _LIBCPP_INLINE_VISIBILITY const_reference front() const {return __make_ref(0);} | 
|  | 2345 | _LIBCPP_INLINE_VISIBILITY reference back() {return __make_ref(__size_ - 1);} | 
|  | 2346 | _LIBCPP_INLINE_VISIBILITY const_reference back() const {return __make_ref(__size_ - 1);} | 
|  | 2347 |  | 
|  | 2348 | void push_back(const value_type& __x); | 
| Marshall Clow | 198a2a5 | 2013-08-13 23:54:12 | [diff] [blame] | 2349 | #if _LIBCPP_STD_VER > 11 | 
|  | 2350 | template <class... _Args> | 
| Marshall Clow | 4e42dc9 | 2017-01-24 23:09:12 | [diff] [blame] | 2351 | #if _LIBCPP_STD_VER > 14 | 
|  | 2352 | _LIBCPP_INLINE_VISIBILITY reference emplace_back(_Args&&... __args) | 
|  | 2353 | #else | 
|  | 2354 | _LIBCPP_INLINE_VISIBILITY void emplace_back(_Args&&... __args) | 
|  | 2355 | #endif | 
|  | 2356 | { | 
| Eric Fiselier | 3816ef9 | 2016-07-21 03:20:17 | [diff] [blame] | 2357 | push_back ( value_type ( _VSTD::forward<_Args>(__args)... )); | 
| Marshall Clow | 4e42dc9 | 2017-01-24 23:09:12 | [diff] [blame] | 2358 | #if _LIBCPP_STD_VER > 14 | 
| Eric Fiselier | 3816ef9 | 2016-07-21 03:20:17 | [diff] [blame] | 2359 | return this->back(); | 
| Marshall Clow | 4e42dc9 | 2017-01-24 23:09:12 | [diff] [blame] | 2360 | #endif | 
| Eric Fiselier | 3816ef9 | 2016-07-21 03:20:17 | [diff] [blame] | 2361 | } | 
| Marshall Clow | 198a2a5 | 2013-08-13 23:54:12 | [diff] [blame] | 2362 | #endif | 
|  | 2363 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2364 | _LIBCPP_INLINE_VISIBILITY void pop_back() {--__size_;} | 
|  | 2365 |  | 
| Marshall Clow | 198a2a5 | 2013-08-13 23:54:12 | [diff] [blame] | 2366 | #if _LIBCPP_STD_VER > 11 | 
|  | 2367 | template <class... _Args> | 
|  | 2368 | _LIBCPP_INLINE_VISIBILITY iterator emplace(const_iterator position, _Args&&... __args) | 
|  | 2369 | { return insert ( position, value_type ( _VSTD::forward<_Args>(__args)... )); } | 
|  | 2370 | #endif | 
|  | 2371 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2372 | iterator insert(const_iterator __position, const value_type& __x); | 
|  | 2373 | iterator insert(const_iterator __position, size_type __n, const value_type& __x); | 
|  | 2374 | iterator insert(const_iterator __position, size_type __n, const_reference __x); | 
|  | 2375 | template <class _InputIterator> | 
|  | 2376 | typename enable_if | 
|  | 2377 | < | 
|  | 2378 | __is_input_iterator <_InputIterator>::value && | 
|  | 2379 | !__is_forward_iterator<_InputIterator>::value, | 
|  | 2380 | iterator | 
|  | 2381 | >::type | 
|  | 2382 | insert(const_iterator __position, _InputIterator __first, _InputIterator __last); | 
|  | 2383 | template <class _ForwardIterator> | 
|  | 2384 | typename enable_if | 
|  | 2385 | < | 
|  | 2386 | __is_forward_iterator<_ForwardIterator>::value, | 
|  | 2387 | iterator | 
|  | 2388 | >::type | 
|  | 2389 | insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last); | 
| Howard Hinnant | e3e3291 | 2011-08-12 21:56:02 | [diff] [blame] | 2390 | #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS | 
| Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 | [diff] [blame] | 2391 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2392 | iterator insert(const_iterator __position, initializer_list<value_type> __il) | 
|  | 2393 | {return insert(__position, __il.begin(), __il.end());} | 
| Howard Hinnant | e3e3291 | 2011-08-12 21:56:02 | [diff] [blame] | 2394 | #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2395 |  | 
| Howard Hinnant | 2d72b1e | 2010-12-17 14:46:43 | [diff] [blame] | 2396 | _LIBCPP_INLINE_VISIBILITY iterator erase(const_iterator __position); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2397 | iterator erase(const_iterator __first, const_iterator __last); | 
|  | 2398 |  | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 2399 | _LIBCPP_INLINE_VISIBILITY | 
|  | 2400 | void clear() _NOEXCEPT {__size_ = 0;} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2401 |  | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 2402 | void swap(vector&) | 
| Marshall Clow | 7d914d1 | 2015-07-13 20:04:56 | [diff] [blame] | 2403 | #if _LIBCPP_STD_VER >= 14 | 
|  | 2404 | _NOEXCEPT; | 
|  | 2405 | #else | 
| Eric Fiselier | fb34238 | 2016-12-28 06:06:09 | [diff] [blame] | 2406 | _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || | 
| Marshall Clow | 7d914d1 | 2015-07-13 20:04:56 | [diff] [blame] | 2407 | __is_nothrow_swappable<allocator_type>::value); | 
|  | 2408 | #endif | 
| Marshall Clow | 005c60b | 2016-04-07 14:20:31 | [diff] [blame] | 2409 | static void swap(reference __x, reference __y) _NOEXCEPT { _VSTD::swap(__x, __y); } | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2410 |  | 
|  | 2411 | void resize(size_type __sz, value_type __x = false); | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 2412 | void flip() _NOEXCEPT; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2413 |  | 
|  | 2414 | bool __invariants() const; | 
|  | 2415 |  | 
|  | 2416 | private: | 
| Howard Hinnant | 2d72b1e | 2010-12-17 14:46:43 | [diff] [blame] | 2417 | _LIBCPP_INLINE_VISIBILITY void __invalidate_all_iterators(); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2418 | void allocate(size_type __n); | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 2419 | void deallocate() _NOEXCEPT; | 
|  | 2420 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 7f76450 | 2013-08-14 18:00:20 | [diff] [blame] | 2421 | static size_type __align_it(size_type __new_size) _NOEXCEPT | 
| Marshall Clow | 0d1965d | 2014-07-28 15:02:42 | [diff] [blame] | 2422 | {return __new_size + (__bits_per_word-1) & ~((size_type)__bits_per_word-1);}; | 
| Howard Hinnant | 2d72b1e | 2010-12-17 14:46:43 | [diff] [blame] | 2423 | _LIBCPP_INLINE_VISIBILITY size_type __recommend(size_type __new_size) const; | 
|  | 2424 | _LIBCPP_INLINE_VISIBILITY void __construct_at_end(size_type __n, bool __x); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2425 | template <class _ForwardIterator> | 
|  | 2426 | typename enable_if | 
|  | 2427 | < | 
|  | 2428 | __is_forward_iterator<_ForwardIterator>::value, | 
|  | 2429 | void | 
|  | 2430 | >::type | 
|  | 2431 | __construct_at_end(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 2432 | void __append(size_type __n, const_reference __x); | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 2433 | _LIBCPP_INLINE_VISIBILITY | 
|  | 2434 | reference __make_ref(size_type __pos) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2435 | {return reference(__begin_ + __pos / __bits_per_word, __storage_type(1) << __pos % __bits_per_word);} | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 2436 | _LIBCPP_INLINE_VISIBILITY | 
|  | 2437 | const_reference __make_ref(size_type __pos) const _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2438 | {return const_reference(__begin_ + __pos / __bits_per_word, __storage_type(1) << __pos % __bits_per_word);} | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 2439 | _LIBCPP_INLINE_VISIBILITY | 
|  | 2440 | iterator __make_iter(size_type __pos) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2441 | {return iterator(__begin_ + __pos / __bits_per_word, static_cast<unsigned>(__pos % __bits_per_word));} | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 2442 | _LIBCPP_INLINE_VISIBILITY | 
|  | 2443 | const_iterator __make_iter(size_type __pos) const _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2444 | {return const_iterator(__begin_ + __pos / __bits_per_word, static_cast<unsigned>(__pos % __bits_per_word));} | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 2445 | _LIBCPP_INLINE_VISIBILITY | 
|  | 2446 | iterator __const_iterator_cast(const_iterator __p) _NOEXCEPT | 
| Howard Hinnant | 2c39cbe | 2013-06-27 19:35:32 | [diff] [blame] | 2447 | {return begin() + (__p - cbegin());} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2448 |  | 
| Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 | [diff] [blame] | 2449 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2450 | void __copy_assign_alloc(const vector& __v) | 
|  | 2451 | {__copy_assign_alloc(__v, integral_constant<bool, | 
|  | 2452 | __storage_traits::propagate_on_container_copy_assignment::value>());} | 
| Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 | [diff] [blame] | 2453 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2454 | void __copy_assign_alloc(const vector& __c, true_type) | 
|  | 2455 | { | 
|  | 2456 | if (__alloc() != __c.__alloc()) | 
|  | 2457 | deallocate(); | 
|  | 2458 | __alloc() = __c.__alloc(); | 
|  | 2459 | } | 
|  | 2460 |  | 
| Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 | [diff] [blame] | 2461 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | ec3773c | 2011-12-01 20:21:04 | [diff] [blame] | 2462 | void __copy_assign_alloc(const vector&, false_type) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2463 | {} | 
|  | 2464 |  | 
|  | 2465 | void __move_assign(vector& __c, false_type); | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 2466 | void __move_assign(vector& __c, true_type) | 
|  | 2467 | _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value); | 
| Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 | [diff] [blame] | 2468 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2469 | void __move_assign_alloc(vector& __c) | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 2470 | _NOEXCEPT_( | 
|  | 2471 | !__storage_traits::propagate_on_container_move_assignment::value || | 
|  | 2472 | is_nothrow_move_assignable<allocator_type>::value) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2473 | {__move_assign_alloc(__c, integral_constant<bool, | 
|  | 2474 | __storage_traits::propagate_on_container_move_assignment::value>());} | 
| Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 | [diff] [blame] | 2475 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 9cbee43 | 2011-09-02 20:42:31 | [diff] [blame] | 2476 | void __move_assign_alloc(vector& __c, true_type) | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 2477 | _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2478 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 2479 | __alloc() = _VSTD::move(__c.__alloc()); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2480 | } | 
|  | 2481 |  | 
| Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 | [diff] [blame] | 2482 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | ec3773c | 2011-12-01 20:21:04 | [diff] [blame] | 2483 | void __move_assign_alloc(vector&, false_type) | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 2484 | _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2485 | {} | 
|  | 2486 |  | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 2487 | size_t __hash_code() const _NOEXCEPT; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2488 |  | 
|  | 2489 | friend class __bit_reference<vector>; | 
|  | 2490 | friend class __bit_const_reference<vector>; | 
|  | 2491 | friend class __bit_iterator<vector, false>; | 
|  | 2492 | friend class __bit_iterator<vector, true>; | 
| Howard Hinnant | 4ae952a | 2012-08-17 17:10:18 | [diff] [blame] | 2493 | friend struct __bit_array<vector>; | 
| Eric Fiselier | c3589a8 | 2017-01-04 23:56:00 | [diff] [blame] | 2494 | friend struct _LIBCPP_TEMPLATE_VIS hash<vector>; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2495 | }; | 
|  | 2496 |  | 
|  | 2497 | template <class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 | [diff] [blame] | 2498 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2499 | void | 
|  | 2500 | vector<bool, _Allocator>::__invalidate_all_iterators() | 
|  | 2501 | { | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2502 | } | 
|  | 2503 |  | 
|  | 2504 | // Allocate space for __n objects | 
|  | 2505 | // throws length_error if __n > max_size() | 
|  | 2506 | // throws (probably bad_alloc) if memory run out | 
|  | 2507 | // Precondition: __begin_ == __end_ == __cap() == 0 | 
|  | 2508 | // Precondition: __n > 0 | 
|  | 2509 | // Postcondition: capacity() == __n | 
|  | 2510 | // Postcondition: size() == 0 | 
|  | 2511 | template <class _Allocator> | 
|  | 2512 | void | 
|  | 2513 | vector<bool, _Allocator>::allocate(size_type __n) | 
|  | 2514 | { | 
|  | 2515 | if (__n > max_size()) | 
|  | 2516 | this->__throw_length_error(); | 
|  | 2517 | __n = __external_cap_to_internal(__n); | 
|  | 2518 | this->__begin_ = __storage_traits::allocate(this->__alloc(), __n); | 
|  | 2519 | this->__size_ = 0; | 
|  | 2520 | this->__cap() = __n; | 
|  | 2521 | } | 
|  | 2522 |  | 
|  | 2523 | template <class _Allocator> | 
|  | 2524 | void | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 2525 | vector<bool, _Allocator>::deallocate() _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2526 | { | 
| Howard Hinnant | 2c39cbe | 2013-06-27 19:35:32 | [diff] [blame] | 2527 | if (this->__begin_ != nullptr) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2528 | { | 
|  | 2529 | __storage_traits::deallocate(this->__alloc(), this->__begin_, __cap()); | 
|  | 2530 | __invalidate_all_iterators(); | 
| Howard Hinnant | 2c39cbe | 2013-06-27 19:35:32 | [diff] [blame] | 2531 | this->__begin_ = nullptr; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2532 | this->__size_ = this->__cap() = 0; | 
|  | 2533 | } | 
|  | 2534 | } | 
|  | 2535 |  | 
|  | 2536 | template <class _Allocator> | 
|  | 2537 | typename vector<bool, _Allocator>::size_type | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 2538 | vector<bool, _Allocator>::max_size() const _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2539 | { | 
|  | 2540 | size_type __amax = __storage_traits::max_size(__alloc()); | 
|  | 2541 | size_type __nmax = numeric_limits<size_type>::max() / 2; // end() >= begin(), always | 
|  | 2542 | if (__nmax / __bits_per_word <= __amax) | 
|  | 2543 | return __nmax; | 
|  | 2544 | return __internal_cap_to_external(__amax); | 
|  | 2545 | } | 
|  | 2546 |  | 
|  | 2547 | // Precondition: __new_size > capacity() | 
|  | 2548 | template <class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 | [diff] [blame] | 2549 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2550 | typename vector<bool, _Allocator>::size_type | 
|  | 2551 | vector<bool, _Allocator>::__recommend(size_type __new_size) const | 
|  | 2552 | { | 
|  | 2553 | const size_type __ms = max_size(); | 
|  | 2554 | if (__new_size > __ms) | 
|  | 2555 | this->__throw_length_error(); | 
|  | 2556 | const size_type __cap = capacity(); | 
|  | 2557 | if (__cap >= __ms / 2) | 
|  | 2558 | return __ms; | 
| Howard Hinnant | 7f76450 | 2013-08-14 18:00:20 | [diff] [blame] | 2559 | return _VSTD::max(2*__cap, __align_it(__new_size)); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2560 | } | 
|  | 2561 |  | 
|  | 2562 | // Default constructs __n objects starting at __end_ | 
|  | 2563 | // Precondition: __n > 0 | 
|  | 2564 | // Precondition: size() + __n <= capacity() | 
|  | 2565 | // Postcondition: size() == size() + __n | 
|  | 2566 | template <class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 | [diff] [blame] | 2567 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2568 | void | 
|  | 2569 | vector<bool, _Allocator>::__construct_at_end(size_type __n, bool __x) | 
|  | 2570 | { | 
|  | 2571 | size_type __old_size = this->__size_; | 
|  | 2572 | this->__size_ += __n; | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 2573 | _VSTD::fill_n(__make_iter(__old_size), __n, __x); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2574 | } | 
|  | 2575 |  | 
|  | 2576 | template <class _Allocator> | 
|  | 2577 | template <class _ForwardIterator> | 
|  | 2578 | typename enable_if | 
|  | 2579 | < | 
|  | 2580 | __is_forward_iterator<_ForwardIterator>::value, | 
|  | 2581 | void | 
|  | 2582 | >::type | 
|  | 2583 | vector<bool, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last) | 
|  | 2584 | { | 
|  | 2585 | size_type __old_size = this->__size_; | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 2586 | this->__size_ += _VSTD::distance(__first, __last); | 
|  | 2587 | _VSTD::copy(__first, __last, __make_iter(__old_size)); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2588 | } | 
|  | 2589 |  | 
|  | 2590 | template <class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 | [diff] [blame] | 2591 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2592 | vector<bool, _Allocator>::vector() | 
| Marshall Clow | c912c0c | 2015-06-04 02:05:41 | [diff] [blame] | 2593 | _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value) | 
| Howard Hinnant | 2c39cbe | 2013-06-27 19:35:32 | [diff] [blame] | 2594 | : __begin_(nullptr), | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2595 | __size_(0), | 
|  | 2596 | __cap_alloc_(0) | 
|  | 2597 | { | 
|  | 2598 | } | 
|  | 2599 |  | 
|  | 2600 | template <class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 | [diff] [blame] | 2601 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2602 | vector<bool, _Allocator>::vector(const allocator_type& __a) | 
| Marshall Clow | 127db91 | 2015-06-04 00:10:20 | [diff] [blame] | 2603 | #if _LIBCPP_STD_VER <= 14 | 
|  | 2604 | _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value) | 
|  | 2605 | #else | 
|  | 2606 | _NOEXCEPT | 
|  | 2607 | #endif | 
| Howard Hinnant | 2c39cbe | 2013-06-27 19:35:32 | [diff] [blame] | 2608 | : __begin_(nullptr), | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2609 | __size_(0), | 
|  | 2610 | __cap_alloc_(0, static_cast<__storage_allocator>(__a)) | 
|  | 2611 | { | 
|  | 2612 | } | 
|  | 2613 |  | 
|  | 2614 | template <class _Allocator> | 
|  | 2615 | vector<bool, _Allocator>::vector(size_type __n) | 
| Howard Hinnant | 2c39cbe | 2013-06-27 19:35:32 | [diff] [blame] | 2616 | : __begin_(nullptr), | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2617 | __size_(0), | 
|  | 2618 | __cap_alloc_(0) | 
|  | 2619 | { | 
|  | 2620 | if (__n > 0) | 
|  | 2621 | { | 
|  | 2622 | allocate(__n); | 
|  | 2623 | __construct_at_end(__n, false); | 
|  | 2624 | } | 
|  | 2625 | } | 
|  | 2626 |  | 
| Marshall Clow | a49a2c9 | 2013-09-14 00:47:59 | [diff] [blame] | 2627 | #if _LIBCPP_STD_VER > 11 | 
|  | 2628 | template <class _Allocator> | 
|  | 2629 | vector<bool, _Allocator>::vector(size_type __n, const allocator_type& __a) | 
|  | 2630 | : __begin_(nullptr), | 
|  | 2631 | __size_(0), | 
|  | 2632 | __cap_alloc_(0, static_cast<__storage_allocator>(__a)) | 
|  | 2633 | { | 
|  | 2634 | if (__n > 0) | 
|  | 2635 | { | 
|  | 2636 | allocate(__n); | 
|  | 2637 | __construct_at_end(__n, false); | 
|  | 2638 | } | 
|  | 2639 | } | 
|  | 2640 | #endif | 
|  | 2641 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2642 | template <class _Allocator> | 
|  | 2643 | vector<bool, _Allocator>::vector(size_type __n, const value_type& __x) | 
| Howard Hinnant | 2c39cbe | 2013-06-27 19:35:32 | [diff] [blame] | 2644 | : __begin_(nullptr), | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2645 | __size_(0), | 
|  | 2646 | __cap_alloc_(0) | 
|  | 2647 | { | 
|  | 2648 | if (__n > 0) | 
|  | 2649 | { | 
|  | 2650 | allocate(__n); | 
|  | 2651 | __construct_at_end(__n, __x); | 
|  | 2652 | } | 
|  | 2653 | } | 
|  | 2654 |  | 
|  | 2655 | template <class _Allocator> | 
|  | 2656 | vector<bool, _Allocator>::vector(size_type __n, const value_type& __x, const allocator_type& __a) | 
| Howard Hinnant | 2c39cbe | 2013-06-27 19:35:32 | [diff] [blame] | 2657 | : __begin_(nullptr), | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2658 | __size_(0), | 
|  | 2659 | __cap_alloc_(0, static_cast<__storage_allocator>(__a)) | 
|  | 2660 | { | 
|  | 2661 | if (__n > 0) | 
|  | 2662 | { | 
|  | 2663 | allocate(__n); | 
|  | 2664 | __construct_at_end(__n, __x); | 
|  | 2665 | } | 
|  | 2666 | } | 
|  | 2667 |  | 
|  | 2668 | template <class _Allocator> | 
|  | 2669 | template <class _InputIterator> | 
|  | 2670 | vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last, | 
|  | 2671 | typename enable_if<__is_input_iterator <_InputIterator>::value && | 
|  | 2672 | !__is_forward_iterator<_InputIterator>::value>::type*) | 
| Howard Hinnant | 2c39cbe | 2013-06-27 19:35:32 | [diff] [blame] | 2673 | : __begin_(nullptr), | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2674 | __size_(0), | 
|  | 2675 | __cap_alloc_(0) | 
|  | 2676 | { | 
|  | 2677 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
|  | 2678 | try | 
|  | 2679 | { | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 2680 | #endif // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2681 | for (; __first != __last; ++__first) | 
|  | 2682 | push_back(*__first); | 
|  | 2683 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
|  | 2684 | } | 
|  | 2685 | catch (...) | 
|  | 2686 | { | 
| Howard Hinnant | 2c39cbe | 2013-06-27 19:35:32 | [diff] [blame] | 2687 | if (__begin_ != nullptr) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2688 | __storage_traits::deallocate(__alloc(), __begin_, __cap()); | 
|  | 2689 | __invalidate_all_iterators(); | 
|  | 2690 | throw; | 
|  | 2691 | } | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 2692 | #endif // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2693 | } | 
|  | 2694 |  | 
|  | 2695 | template <class _Allocator> | 
|  | 2696 | template <class _InputIterator> | 
|  | 2697 | vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a, | 
|  | 2698 | typename enable_if<__is_input_iterator <_InputIterator>::value && | 
|  | 2699 | !__is_forward_iterator<_InputIterator>::value>::type*) | 
| Howard Hinnant | 2c39cbe | 2013-06-27 19:35:32 | [diff] [blame] | 2700 | : __begin_(nullptr), | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2701 | __size_(0), | 
|  | 2702 | __cap_alloc_(0, static_cast<__storage_allocator>(__a)) | 
|  | 2703 | { | 
|  | 2704 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
|  | 2705 | try | 
|  | 2706 | { | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 2707 | #endif // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2708 | for (; __first != __last; ++__first) | 
|  | 2709 | push_back(*__first); | 
|  | 2710 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
|  | 2711 | } | 
|  | 2712 | catch (...) | 
|  | 2713 | { | 
| Howard Hinnant | 2c39cbe | 2013-06-27 19:35:32 | [diff] [blame] | 2714 | if (__begin_ != nullptr) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2715 | __storage_traits::deallocate(__alloc(), __begin_, __cap()); | 
|  | 2716 | __invalidate_all_iterators(); | 
|  | 2717 | throw; | 
|  | 2718 | } | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 2719 | #endif // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2720 | } | 
|  | 2721 |  | 
|  | 2722 | template <class _Allocator> | 
|  | 2723 | template <class _ForwardIterator> | 
|  | 2724 | vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last, | 
|  | 2725 | typename enable_if<__is_forward_iterator<_ForwardIterator>::value>::type*) | 
| Howard Hinnant | 2c39cbe | 2013-06-27 19:35:32 | [diff] [blame] | 2726 | : __begin_(nullptr), | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2727 | __size_(0), | 
|  | 2728 | __cap_alloc_(0) | 
|  | 2729 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 2730 | size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last)); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2731 | if (__n > 0) | 
|  | 2732 | { | 
|  | 2733 | allocate(__n); | 
|  | 2734 | __construct_at_end(__first, __last); | 
|  | 2735 | } | 
|  | 2736 | } | 
|  | 2737 |  | 
|  | 2738 | template <class _Allocator> | 
|  | 2739 | template <class _ForwardIterator> | 
|  | 2740 | vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a, | 
|  | 2741 | typename enable_if<__is_forward_iterator<_ForwardIterator>::value>::type*) | 
| Howard Hinnant | 2c39cbe | 2013-06-27 19:35:32 | [diff] [blame] | 2742 | : __begin_(nullptr), | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2743 | __size_(0), | 
|  | 2744 | __cap_alloc_(0, static_cast<__storage_allocator>(__a)) | 
|  | 2745 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 2746 | size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last)); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2747 | if (__n > 0) | 
|  | 2748 | { | 
|  | 2749 | allocate(__n); | 
|  | 2750 | __construct_at_end(__first, __last); | 
|  | 2751 | } | 
|  | 2752 | } | 
|  | 2753 |  | 
| Howard Hinnant | e3e3291 | 2011-08-12 21:56:02 | [diff] [blame] | 2754 | #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS | 
|  | 2755 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2756 | template <class _Allocator> | 
|  | 2757 | vector<bool, _Allocator>::vector(initializer_list<value_type> __il) | 
| Howard Hinnant | 2c39cbe | 2013-06-27 19:35:32 | [diff] [blame] | 2758 | : __begin_(nullptr), | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2759 | __size_(0), | 
|  | 2760 | __cap_alloc_(0) | 
|  | 2761 | { | 
|  | 2762 | size_type __n = static_cast<size_type>(__il.size()); | 
|  | 2763 | if (__n > 0) | 
|  | 2764 | { | 
|  | 2765 | allocate(__n); | 
|  | 2766 | __construct_at_end(__il.begin(), __il.end()); | 
|  | 2767 | } | 
|  | 2768 | } | 
|  | 2769 |  | 
|  | 2770 | template <class _Allocator> | 
|  | 2771 | vector<bool, _Allocator>::vector(initializer_list<value_type> __il, const allocator_type& __a) | 
| Howard Hinnant | 2c39cbe | 2013-06-27 19:35:32 | [diff] [blame] | 2772 | : __begin_(nullptr), | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2773 | __size_(0), | 
|  | 2774 | __cap_alloc_(0, static_cast<__storage_allocator>(__a)) | 
|  | 2775 | { | 
|  | 2776 | size_type __n = static_cast<size_type>(__il.size()); | 
|  | 2777 | if (__n > 0) | 
|  | 2778 | { | 
|  | 2779 | allocate(__n); | 
|  | 2780 | __construct_at_end(__il.begin(), __il.end()); | 
|  | 2781 | } | 
|  | 2782 | } | 
|  | 2783 |  | 
| Howard Hinnant | e3e3291 | 2011-08-12 21:56:02 | [diff] [blame] | 2784 | #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS | 
|  | 2785 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2786 | template <class _Allocator> | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2787 | vector<bool, _Allocator>::~vector() | 
|  | 2788 | { | 
| Howard Hinnant | 2c39cbe | 2013-06-27 19:35:32 | [diff] [blame] | 2789 | if (__begin_ != nullptr) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2790 | __storage_traits::deallocate(__alloc(), __begin_, __cap()); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2791 | __invalidate_all_iterators(); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2792 | } | 
|  | 2793 |  | 
|  | 2794 | template <class _Allocator> | 
|  | 2795 | vector<bool, _Allocator>::vector(const vector& __v) | 
| Howard Hinnant | 2c39cbe | 2013-06-27 19:35:32 | [diff] [blame] | 2796 | : __begin_(nullptr), | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2797 | __size_(0), | 
|  | 2798 | __cap_alloc_(0, __storage_traits::select_on_container_copy_construction(__v.__alloc())) | 
|  | 2799 | { | 
|  | 2800 | if (__v.size() > 0) | 
|  | 2801 | { | 
|  | 2802 | allocate(__v.size()); | 
|  | 2803 | __construct_at_end(__v.begin(), __v.end()); | 
|  | 2804 | } | 
|  | 2805 | } | 
|  | 2806 |  | 
|  | 2807 | template <class _Allocator> | 
|  | 2808 | vector<bool, _Allocator>::vector(const vector& __v, const allocator_type& __a) | 
| Howard Hinnant | 2c39cbe | 2013-06-27 19:35:32 | [diff] [blame] | 2809 | : __begin_(nullptr), | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2810 | __size_(0), | 
|  | 2811 | __cap_alloc_(0, __a) | 
|  | 2812 | { | 
|  | 2813 | if (__v.size() > 0) | 
|  | 2814 | { | 
|  | 2815 | allocate(__v.size()); | 
|  | 2816 | __construct_at_end(__v.begin(), __v.end()); | 
|  | 2817 | } | 
|  | 2818 | } | 
|  | 2819 |  | 
|  | 2820 | template <class _Allocator> | 
|  | 2821 | vector<bool, _Allocator>& | 
|  | 2822 | vector<bool, _Allocator>::operator=(const vector& __v) | 
|  | 2823 | { | 
|  | 2824 | if (this != &__v) | 
|  | 2825 | { | 
|  | 2826 | __copy_assign_alloc(__v); | 
|  | 2827 | if (__v.__size_) | 
|  | 2828 | { | 
|  | 2829 | if (__v.__size_ > capacity()) | 
|  | 2830 | { | 
|  | 2831 | deallocate(); | 
|  | 2832 | allocate(__v.__size_); | 
|  | 2833 | } | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 2834 | _VSTD::copy(__v.__begin_, __v.__begin_ + __external_cap_to_internal(__v.__size_), __begin_); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2835 | } | 
|  | 2836 | __size_ = __v.__size_; | 
|  | 2837 | } | 
|  | 2838 | return *this; | 
|  | 2839 | } | 
|  | 2840 |  | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 | [diff] [blame] | 2841 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
|  | 2842 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2843 | template <class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 | [diff] [blame] | 2844 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2845 | vector<bool, _Allocator>::vector(vector&& __v) | 
| Marshall Clow | 119ed47 | 2015-07-14 14:46:32 | [diff] [blame] | 2846 | #if _LIBCPP_STD_VER > 14 | 
|  | 2847 | _NOEXCEPT | 
|  | 2848 | #else | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 2849 | _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value) | 
| Marshall Clow | 119ed47 | 2015-07-14 14:46:32 | [diff] [blame] | 2850 | #endif | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2851 | : __begin_(__v.__begin_), | 
|  | 2852 | __size_(__v.__size_), | 
|  | 2853 | __cap_alloc_(__v.__cap_alloc_) | 
|  | 2854 | { | 
| Howard Hinnant | 2c39cbe | 2013-06-27 19:35:32 | [diff] [blame] | 2855 | __v.__begin_ = nullptr; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2856 | __v.__size_ = 0; | 
|  | 2857 | __v.__cap() = 0; | 
|  | 2858 | } | 
|  | 2859 |  | 
|  | 2860 | template <class _Allocator> | 
|  | 2861 | vector<bool, _Allocator>::vector(vector&& __v, const allocator_type& __a) | 
| Howard Hinnant | 2c39cbe | 2013-06-27 19:35:32 | [diff] [blame] | 2862 | : __begin_(nullptr), | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2863 | __size_(0), | 
|  | 2864 | __cap_alloc_(0, __a) | 
|  | 2865 | { | 
|  | 2866 | if (__a == allocator_type(__v.__alloc())) | 
|  | 2867 | { | 
|  | 2868 | this->__begin_ = __v.__begin_; | 
|  | 2869 | this->__size_ = __v.__size_; | 
|  | 2870 | this->__cap() = __v.__cap(); | 
|  | 2871 | __v.__begin_ = nullptr; | 
|  | 2872 | __v.__cap() = __v.__size_ = 0; | 
|  | 2873 | } | 
|  | 2874 | else if (__v.size() > 0) | 
|  | 2875 | { | 
|  | 2876 | allocate(__v.size()); | 
|  | 2877 | __construct_at_end(__v.begin(), __v.end()); | 
|  | 2878 | } | 
|  | 2879 | } | 
|  | 2880 |  | 
|  | 2881 | template <class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 | [diff] [blame] | 2882 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2883 | vector<bool, _Allocator>& | 
|  | 2884 | vector<bool, _Allocator>::operator=(vector&& __v) | 
| Marshall Clow | af961ed | 2015-08-18 18:57:00 | [diff] [blame] | 2885 | _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value)) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2886 | { | 
|  | 2887 | __move_assign(__v, integral_constant<bool, | 
|  | 2888 | __storage_traits::propagate_on_container_move_assignment::value>()); | 
| Argyrios Kyrtzidis | 1dc6f7a | 2012-10-13 02:03:45 | [diff] [blame] | 2889 | return *this; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2890 | } | 
|  | 2891 |  | 
|  | 2892 | template <class _Allocator> | 
|  | 2893 | void | 
|  | 2894 | vector<bool, _Allocator>::__move_assign(vector& __c, false_type) | 
|  | 2895 | { | 
|  | 2896 | if (__alloc() != __c.__alloc()) | 
|  | 2897 | assign(__c.begin(), __c.end()); | 
|  | 2898 | else | 
|  | 2899 | __move_assign(__c, true_type()); | 
|  | 2900 | } | 
|  | 2901 |  | 
|  | 2902 | template <class _Allocator> | 
|  | 2903 | void | 
|  | 2904 | vector<bool, _Allocator>::__move_assign(vector& __c, true_type) | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 2905 | _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2906 | { | 
|  | 2907 | deallocate(); | 
| Marshall Clow | db5e54d | 2014-07-21 15:15:15 | [diff] [blame] | 2908 | __move_assign_alloc(__c); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2909 | this->__begin_ = __c.__begin_; | 
|  | 2910 | this->__size_ = __c.__size_; | 
|  | 2911 | this->__cap() = __c.__cap(); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2912 | __c.__begin_ = nullptr; | 
|  | 2913 | __c.__cap() = __c.__size_ = 0; | 
|  | 2914 | } | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 | [diff] [blame] | 2915 |  | 
|  | 2916 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2917 |  | 
|  | 2918 | template <class _Allocator> | 
|  | 2919 | void | 
|  | 2920 | vector<bool, _Allocator>::assign(size_type __n, const value_type& __x) | 
|  | 2921 | { | 
|  | 2922 | __size_ = 0; | 
|  | 2923 | if (__n > 0) | 
|  | 2924 | { | 
|  | 2925 | size_type __c = capacity(); | 
|  | 2926 | if (__n <= __c) | 
|  | 2927 | __size_ = __n; | 
|  | 2928 | else | 
|  | 2929 | { | 
|  | 2930 | vector __v(__alloc()); | 
|  | 2931 | __v.reserve(__recommend(__n)); | 
|  | 2932 | __v.__size_ = __n; | 
|  | 2933 | swap(__v); | 
|  | 2934 | } | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 2935 | _VSTD::fill_n(begin(), __n, __x); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2936 | } | 
| Eric Fiselier | fb34238 | 2016-12-28 06:06:09 | [diff] [blame] | 2937 | __invalidate_all_iterators(); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2938 | } | 
|  | 2939 |  | 
|  | 2940 | template <class _Allocator> | 
|  | 2941 | template <class _InputIterator> | 
|  | 2942 | typename enable_if | 
|  | 2943 | < | 
|  | 2944 | __is_input_iterator<_InputIterator>::value && | 
|  | 2945 | !__is_forward_iterator<_InputIterator>::value, | 
|  | 2946 | void | 
|  | 2947 | >::type | 
|  | 2948 | vector<bool, _Allocator>::assign(_InputIterator __first, _InputIterator __last) | 
|  | 2949 | { | 
|  | 2950 | clear(); | 
|  | 2951 | for (; __first != __last; ++__first) | 
|  | 2952 | push_back(*__first); | 
|  | 2953 | } | 
|  | 2954 |  | 
|  | 2955 | template <class _Allocator> | 
|  | 2956 | template <class _ForwardIterator> | 
|  | 2957 | typename enable_if | 
|  | 2958 | < | 
|  | 2959 | __is_forward_iterator<_ForwardIterator>::value, | 
|  | 2960 | void | 
|  | 2961 | >::type | 
|  | 2962 | vector<bool, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __last) | 
|  | 2963 | { | 
|  | 2964 | clear(); | 
| Eric Fiselier | 0e5ebbc | 2016-12-23 23:37:52 | [diff] [blame] | 2965 | difference_type __ns = _VSTD::distance(__first, __last); | 
|  | 2966 | _LIBCPP_ASSERT(__ns >= 0, "invalid range specified"); | 
|  | 2967 | const size_t __n = static_cast<size_type>(__ns); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2968 | if (__n) | 
|  | 2969 | { | 
|  | 2970 | if (__n > capacity()) | 
|  | 2971 | { | 
|  | 2972 | deallocate(); | 
|  | 2973 | allocate(__n); | 
|  | 2974 | } | 
|  | 2975 | __construct_at_end(__first, __last); | 
|  | 2976 | } | 
|  | 2977 | } | 
|  | 2978 |  | 
|  | 2979 | template <class _Allocator> | 
|  | 2980 | void | 
|  | 2981 | vector<bool, _Allocator>::reserve(size_type __n) | 
|  | 2982 | { | 
|  | 2983 | if (__n > capacity()) | 
|  | 2984 | { | 
|  | 2985 | vector __v(this->__alloc()); | 
|  | 2986 | __v.allocate(__n); | 
|  | 2987 | __v.__construct_at_end(this->begin(), this->end()); | 
|  | 2988 | swap(__v); | 
|  | 2989 | __invalidate_all_iterators(); | 
|  | 2990 | } | 
|  | 2991 | } | 
|  | 2992 |  | 
|  | 2993 | template <class _Allocator> | 
|  | 2994 | void | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 2995 | vector<bool, _Allocator>::shrink_to_fit() _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 2996 | { | 
|  | 2997 | if (__external_cap_to_internal(size()) > __cap()) | 
|  | 2998 | { | 
|  | 2999 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
|  | 3000 | try | 
|  | 3001 | { | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 3002 | #endif // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 3003 | vector(*this, allocator_type(__alloc())).swap(*this); | 
|  | 3004 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
|  | 3005 | } | 
|  | 3006 | catch (...) | 
|  | 3007 | { | 
|  | 3008 | } | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 3009 | #endif // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 3010 | } | 
|  | 3011 | } | 
|  | 3012 |  | 
|  | 3013 | template <class _Allocator> | 
|  | 3014 | typename vector<bool, _Allocator>::reference | 
|  | 3015 | vector<bool, _Allocator>::at(size_type __n) | 
|  | 3016 | { | 
|  | 3017 | if (__n >= size()) | 
|  | 3018 | this->__throw_out_of_range(); | 
|  | 3019 | return (*this)[__n]; | 
|  | 3020 | } | 
|  | 3021 |  | 
|  | 3022 | template <class _Allocator> | 
|  | 3023 | typename vector<bool, _Allocator>::const_reference | 
|  | 3024 | vector<bool, _Allocator>::at(size_type __n) const | 
|  | 3025 | { | 
|  | 3026 | if (__n >= size()) | 
|  | 3027 | this->__throw_out_of_range(); | 
|  | 3028 | return (*this)[__n]; | 
|  | 3029 | } | 
|  | 3030 |  | 
|  | 3031 | template <class _Allocator> | 
|  | 3032 | void | 
|  | 3033 | vector<bool, _Allocator>::push_back(const value_type& __x) | 
|  | 3034 | { | 
|  | 3035 | if (this->__size_ == this->capacity()) | 
|  | 3036 | reserve(__recommend(this->__size_ + 1)); | 
|  | 3037 | ++this->__size_; | 
|  | 3038 | back() = __x; | 
|  | 3039 | } | 
|  | 3040 |  | 
|  | 3041 | template <class _Allocator> | 
|  | 3042 | typename vector<bool, _Allocator>::iterator | 
|  | 3043 | vector<bool, _Allocator>::insert(const_iterator __position, const value_type& __x) | 
|  | 3044 | { | 
|  | 3045 | iterator __r; | 
|  | 3046 | if (size() < capacity()) | 
|  | 3047 | { | 
|  | 3048 | const_iterator __old_end = end(); | 
|  | 3049 | ++__size_; | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 3050 | _VSTD::copy_backward(__position, __old_end, end()); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 3051 | __r = __const_iterator_cast(__position); | 
|  | 3052 | } | 
|  | 3053 | else | 
|  | 3054 | { | 
|  | 3055 | vector __v(__alloc()); | 
|  | 3056 | __v.reserve(__recommend(__size_ + 1)); | 
|  | 3057 | __v.__size_ = __size_ + 1; | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 3058 | __r = _VSTD::copy(cbegin(), __position, __v.begin()); | 
|  | 3059 | _VSTD::copy_backward(__position, cend(), __v.end()); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 3060 | swap(__v); | 
|  | 3061 | } | 
|  | 3062 | *__r = __x; | 
|  | 3063 | return __r; | 
|  | 3064 | } | 
|  | 3065 |  | 
|  | 3066 | template <class _Allocator> | 
|  | 3067 | typename vector<bool, _Allocator>::iterator | 
|  | 3068 | vector<bool, _Allocator>::insert(const_iterator __position, size_type __n, const value_type& __x) | 
|  | 3069 | { | 
|  | 3070 | iterator __r; | 
|  | 3071 | size_type __c = capacity(); | 
|  | 3072 | if (__n <= __c && size() <= __c - __n) | 
|  | 3073 | { | 
|  | 3074 | const_iterator __old_end = end(); | 
|  | 3075 | __size_ += __n; | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 3076 | _VSTD::copy_backward(__position, __old_end, end()); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 3077 | __r = __const_iterator_cast(__position); | 
|  | 3078 | } | 
|  | 3079 | else | 
|  | 3080 | { | 
|  | 3081 | vector __v(__alloc()); | 
|  | 3082 | __v.reserve(__recommend(__size_ + __n)); | 
|  | 3083 | __v.__size_ = __size_ + __n; | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 3084 | __r = _VSTD::copy(cbegin(), __position, __v.begin()); | 
|  | 3085 | _VSTD::copy_backward(__position, cend(), __v.end()); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 3086 | swap(__v); | 
|  | 3087 | } | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 3088 | _VSTD::fill_n(__r, __n, __x); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 3089 | return __r; | 
|  | 3090 | } | 
|  | 3091 |  | 
|  | 3092 | template <class _Allocator> | 
|  | 3093 | template <class _InputIterator> | 
|  | 3094 | typename enable_if | 
|  | 3095 | < | 
|  | 3096 | __is_input_iterator <_InputIterator>::value && | 
|  | 3097 | !__is_forward_iterator<_InputIterator>::value, | 
|  | 3098 | typename vector<bool, _Allocator>::iterator | 
|  | 3099 | >::type | 
|  | 3100 | vector<bool, _Allocator>::insert(const_iterator __position, _InputIterator __first, _InputIterator __last) | 
|  | 3101 | { | 
|  | 3102 | difference_type __off = __position - begin(); | 
|  | 3103 | iterator __p = __const_iterator_cast(__position); | 
|  | 3104 | iterator __old_end = end(); | 
|  | 3105 | for (; size() != capacity() && __first != __last; ++__first) | 
|  | 3106 | { | 
|  | 3107 | ++this->__size_; | 
|  | 3108 | back() = *__first; | 
|  | 3109 | } | 
|  | 3110 | vector __v(__alloc()); | 
|  | 3111 | if (__first != __last) | 
|  | 3112 | { | 
|  | 3113 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
|  | 3114 | try | 
|  | 3115 | { | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 3116 | #endif // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 3117 | __v.assign(__first, __last); | 
|  | 3118 | difference_type __old_size = static_cast<difference_type>(__old_end - begin()); | 
|  | 3119 | difference_type __old_p = __p - begin(); | 
|  | 3120 | reserve(__recommend(size() + __v.size())); | 
|  | 3121 | __p = begin() + __old_p; | 
|  | 3122 | __old_end = begin() + __old_size; | 
|  | 3123 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
|  | 3124 | } | 
|  | 3125 | catch (...) | 
|  | 3126 | { | 
|  | 3127 | erase(__old_end, end()); | 
|  | 3128 | throw; | 
|  | 3129 | } | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 3130 | #endif // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 3131 | } | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 3132 | __p = _VSTD::rotate(__p, __old_end, end()); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 3133 | insert(__p, __v.begin(), __v.end()); | 
|  | 3134 | return begin() + __off; | 
|  | 3135 | } | 
|  | 3136 |  | 
|  | 3137 | template <class _Allocator> | 
|  | 3138 | template <class _ForwardIterator> | 
|  | 3139 | typename enable_if | 
|  | 3140 | < | 
|  | 3141 | __is_forward_iterator<_ForwardIterator>::value, | 
|  | 3142 | typename vector<bool, _Allocator>::iterator | 
|  | 3143 | >::type | 
|  | 3144 | vector<bool, _Allocator>::insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last) | 
|  | 3145 | { | 
| Eric Fiselier | a2cd270 | 2016-12-11 05:31:00 | [diff] [blame] | 3146 | const difference_type __n_signed = _VSTD::distance(__first, __last); | 
|  | 3147 | _LIBCPP_ASSERT(__n_signed >= 0, "invalid range specified"); | 
|  | 3148 | const size_type __n = static_cast<size_type>(__n_signed); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 3149 | iterator __r; | 
|  | 3150 | size_type __c = capacity(); | 
|  | 3151 | if (__n <= __c && size() <= __c - __n) | 
|  | 3152 | { | 
|  | 3153 | const_iterator __old_end = end(); | 
|  | 3154 | __size_ += __n; | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 3155 | _VSTD::copy_backward(__position, __old_end, end()); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 3156 | __r = __const_iterator_cast(__position); | 
|  | 3157 | } | 
|  | 3158 | else | 
|  | 3159 | { | 
|  | 3160 | vector __v(__alloc()); | 
|  | 3161 | __v.reserve(__recommend(__size_ + __n)); | 
|  | 3162 | __v.__size_ = __size_ + __n; | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 3163 | __r = _VSTD::copy(cbegin(), __position, __v.begin()); | 
|  | 3164 | _VSTD::copy_backward(__position, cend(), __v.end()); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 3165 | swap(__v); | 
|  | 3166 | } | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 3167 | _VSTD::copy(__first, __last, __r); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 3168 | return __r; | 
|  | 3169 | } | 
|  | 3170 |  | 
|  | 3171 | template <class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 | [diff] [blame] | 3172 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 3173 | typename vector<bool, _Allocator>::iterator | 
|  | 3174 | vector<bool, _Allocator>::erase(const_iterator __position) | 
|  | 3175 | { | 
|  | 3176 | iterator __r = __const_iterator_cast(__position); | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 3177 | _VSTD::copy(__position + 1, this->cend(), __r); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 3178 | --__size_; | 
|  | 3179 | return __r; | 
|  | 3180 | } | 
|  | 3181 |  | 
|  | 3182 | template <class _Allocator> | 
|  | 3183 | typename vector<bool, _Allocator>::iterator | 
|  | 3184 | vector<bool, _Allocator>::erase(const_iterator __first, const_iterator __last) | 
|  | 3185 | { | 
|  | 3186 | iterator __r = __const_iterator_cast(__first); | 
|  | 3187 | difference_type __d = __last - __first; | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 3188 | _VSTD::copy(__last, this->cend(), __r); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 3189 | __size_ -= __d; | 
|  | 3190 | return __r; | 
|  | 3191 | } | 
|  | 3192 |  | 
|  | 3193 | template <class _Allocator> | 
|  | 3194 | void | 
|  | 3195 | vector<bool, _Allocator>::swap(vector& __x) | 
| Marshall Clow | 7d914d1 | 2015-07-13 20:04:56 | [diff] [blame] | 3196 | #if _LIBCPP_STD_VER >= 14 | 
|  | 3197 | _NOEXCEPT | 
|  | 3198 | #else | 
| Eric Fiselier | fb34238 | 2016-12-28 06:06:09 | [diff] [blame] | 3199 | _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || | 
| Marshall Clow | 7d914d1 | 2015-07-13 20:04:56 | [diff] [blame] | 3200 | __is_nothrow_swappable<allocator_type>::value) | 
|  | 3201 | #endif | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 3202 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 3203 | _VSTD::swap(this->__begin_, __x.__begin_); | 
|  | 3204 | _VSTD::swap(this->__size_, __x.__size_); | 
|  | 3205 | _VSTD::swap(this->__cap(), __x.__cap()); | 
| Marshall Clow | 7d914d1 | 2015-07-13 20:04:56 | [diff] [blame] | 3206 | __swap_allocator(this->__alloc(), __x.__alloc(), | 
|  | 3207 | integral_constant<bool, __alloc_traits::propagate_on_container_swap::value>()); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 3208 | } | 
|  | 3209 |  | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 3210 | template <class _Allocator> | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 3211 | void | 
|  | 3212 | vector<bool, _Allocator>::resize(size_type __sz, value_type __x) | 
|  | 3213 | { | 
|  | 3214 | size_type __cs = size(); | 
|  | 3215 | if (__cs < __sz) | 
|  | 3216 | { | 
|  | 3217 | iterator __r; | 
|  | 3218 | size_type __c = capacity(); | 
|  | 3219 | size_type __n = __sz - __cs; | 
|  | 3220 | if (__n <= __c && __cs <= __c - __n) | 
|  | 3221 | { | 
|  | 3222 | __r = end(); | 
|  | 3223 | __size_ += __n; | 
|  | 3224 | } | 
|  | 3225 | else | 
|  | 3226 | { | 
|  | 3227 | vector __v(__alloc()); | 
|  | 3228 | __v.reserve(__recommend(__size_ + __n)); | 
|  | 3229 | __v.__size_ = __size_ + __n; | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 3230 | __r = _VSTD::copy(cbegin(), cend(), __v.begin()); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 3231 | swap(__v); | 
|  | 3232 | } | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 3233 | _VSTD::fill_n(__r, __n, __x); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 3234 | } | 
|  | 3235 | else | 
|  | 3236 | __size_ = __sz; | 
|  | 3237 | } | 
|  | 3238 |  | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 3239 | template <class _Allocator> | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 3240 | void | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 3241 | vector<bool, _Allocator>::flip() _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 3242 | { | 
|  | 3243 | // do middle whole words | 
|  | 3244 | size_type __n = __size_; | 
|  | 3245 | __storage_pointer __p = __begin_; | 
|  | 3246 | for (; __n >= __bits_per_word; ++__p, __n -= __bits_per_word) | 
|  | 3247 | *__p = ~*__p; | 
|  | 3248 | // do last partial word | 
|  | 3249 | if (__n > 0) | 
|  | 3250 | { | 
|  | 3251 | __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n); | 
|  | 3252 | __storage_type __b = *__p & __m; | 
|  | 3253 | *__p &= ~__m; | 
|  | 3254 | *__p |= ~__b & __m; | 
|  | 3255 | } | 
|  | 3256 | } | 
|  | 3257 |  | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 3258 | template <class _Allocator> | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 3259 | bool | 
|  | 3260 | vector<bool, _Allocator>::__invariants() const | 
|  | 3261 | { | 
| Howard Hinnant | 2c39cbe | 2013-06-27 19:35:32 | [diff] [blame] | 3262 | if (this->__begin_ == nullptr) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 3263 | { | 
|  | 3264 | if (this->__size_ != 0 || this->__cap() != 0) | 
|  | 3265 | return false; | 
|  | 3266 | } | 
|  | 3267 | else | 
|  | 3268 | { | 
|  | 3269 | if (this->__cap() == 0) | 
|  | 3270 | return false; | 
|  | 3271 | if (this->__size_ > this->capacity()) | 
|  | 3272 | return false; | 
|  | 3273 | } | 
|  | 3274 | return true; | 
|  | 3275 | } | 
|  | 3276 |  | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 3277 | template <class _Allocator> | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 3278 | size_t | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 3279 | vector<bool, _Allocator>::__hash_code() const _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 3280 | { | 
|  | 3281 | size_t __h = 0; | 
|  | 3282 | // do middle whole words | 
|  | 3283 | size_type __n = __size_; | 
|  | 3284 | __storage_pointer __p = __begin_; | 
|  | 3285 | for (; __n >= __bits_per_word; ++__p, __n -= __bits_per_word) | 
|  | 3286 | __h ^= *__p; | 
|  | 3287 | // do last partial word | 
|  | 3288 | if (__n > 0) | 
|  | 3289 | { | 
|  | 3290 | const __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n); | 
|  | 3291 | __h ^= *__p & __m; | 
|  | 3292 | } | 
|  | 3293 | return __h; | 
|  | 3294 | } | 
|  | 3295 |  | 
|  | 3296 | template <class _Allocator> | 
| Eric Fiselier | c3589a8 | 2017-01-04 23:56:00 | [diff] [blame] | 3297 | struct _LIBCPP_TEMPLATE_VIS hash<vector<bool, _Allocator> > | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 3298 | : public unary_function<vector<bool, _Allocator>, size_t> | 
|  | 3299 | { | 
| Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 | [diff] [blame] | 3300 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 3301 | size_t operator()(const vector<bool, _Allocator>& __vec) const _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 3302 | {return __vec.__hash_code();} | 
|  | 3303 | }; | 
|  | 3304 |  | 
|  | 3305 | template <class _Tp, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 | [diff] [blame] | 3306 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 3307 | bool | 
|  | 3308 | operator==(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) | 
|  | 3309 | { | 
|  | 3310 | const typename vector<_Tp, _Allocator>::size_type __sz = __x.size(); | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 3311 | return __sz == __y.size() && _VSTD::equal(__x.begin(), __x.end(), __y.begin()); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 3312 | } | 
|  | 3313 |  | 
|  | 3314 | template <class _Tp, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 | [diff] [blame] | 3315 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 3316 | bool | 
|  | 3317 | operator!=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) | 
|  | 3318 | { | 
|  | 3319 | return !(__x == __y); | 
|  | 3320 | } | 
|  | 3321 |  | 
|  | 3322 | template <class _Tp, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 | [diff] [blame] | 3323 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 3324 | bool | 
|  | 3325 | operator< (const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) | 
|  | 3326 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 3327 | return _VSTD::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end()); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 3328 | } | 
|  | 3329 |  | 
|  | 3330 | template <class _Tp, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 | [diff] [blame] | 3331 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 3332 | bool | 
|  | 3333 | operator> (const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) | 
|  | 3334 | { | 
|  | 3335 | return __y < __x; | 
|  | 3336 | } | 
|  | 3337 |  | 
|  | 3338 | template <class _Tp, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 | [diff] [blame] | 3339 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 3340 | bool | 
|  | 3341 | operator>=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) | 
|  | 3342 | { | 
|  | 3343 | return !(__x < __y); | 
|  | 3344 | } | 
|  | 3345 |  | 
|  | 3346 | template <class _Tp, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 | [diff] [blame] | 3347 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 3348 | bool | 
|  | 3349 | operator<=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) | 
|  | 3350 | { | 
|  | 3351 | return !(__y < __x); | 
|  | 3352 | } | 
|  | 3353 |  | 
|  | 3354 | template <class _Tp, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 | [diff] [blame] | 3355 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 3356 | void | 
|  | 3357 | swap(vector<_Tp, _Allocator>& __x, vector<_Tp, _Allocator>& __y) | 
| Howard Hinnant | d1d27a4 | 2011-06-03 19:40:40 | [diff] [blame] | 3358 | _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 3359 | { | 
|  | 3360 | __x.swap(__y); | 
|  | 3361 | } | 
|  | 3362 |  | 
|  | 3363 | _LIBCPP_END_NAMESPACE_STD | 
|  | 3364 |  | 
|  | 3365 | #endif // _LIBCPP_VECTOR |